Skip to content

Commit 70469ce

Browse files
committed
Improve check_append error #558
1 parent a0c5159 commit 70469ce

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ 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+
- Improve check_append error #558
2526

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

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)