Skip to content

Commit 0f8af0c

Browse files
committed
Improve check_append error #558
1 parent 919fe68 commit 0f8af0c

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ See [STATUS.md](server/STATUS.md) to learn more about which features will remain
2222
- Fix index issue happening when deleting a single property in a sorted collection #545
2323
- Update JS assets & playwright
2424
- Fix initial indexing bug #560
25-
- Fix errors on succesful export / import #565
25+
- Improve check_append error #558
26+
- Fix errors on successful export / import #565
2627

2728
## [v0.34.0] - 2022-10-31
2829

lib/src/hierarchy.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,24 @@ pub fn check_append(
6969
resource: &Resource,
7070
for_agent: &str,
7171
) -> AtomicResult<String> {
72-
let parent = if let Ok(parent) = resource.get_parent(store) {
73-
parent
74-
} else {
75-
if resource
76-
.get_classes(store)?
77-
.iter()
78-
.map(|c| c.subject.clone())
79-
.collect::<String>()
80-
.contains(urls::DRIVE)
81-
{
82-
return Ok(String::from("Drive without a parent can be created"));
72+
let parent = match resource.get_parent(store) {
73+
Ok(p) => p,
74+
Err(e) => {
75+
if resource
76+
.get_classes(store)?
77+
.iter()
78+
.map(|c| c.subject.clone())
79+
.collect::<String>()
80+
.contains(urls::DRIVE)
81+
{
82+
return Ok(String::from("Drive without a parent can be created"));
83+
}
84+
return Err(AtomicError::unauthorized(format!(
85+
"Can't append to {} because it's parent cannot be found: {}",
86+
resource.get_subject(),
87+
e
88+
)));
8389
}
84-
return Err(AtomicError::unauthorized(format!(
85-
"No parent found for {}",
86-
resource.get_subject()
87-
)));
8890
};
8991
if let Ok(msg) = check_rights(store, &parent, for_agent, Right::Append) {
9092
Ok(msg)

0 commit comments

Comments
 (0)