1use crate::core::metadata::Name;
4use crate::core::object_id::ObjectId;
5use crate::filesystem::path::VirtualPath;
6use crate::security::authorization::{ActorId, Operation};
7
8#[derive(Debug, thiserror::Error, PartialEq, Eq)]
10pub enum Error {
11 #[error("object {0} does not exist")]
13 ObjectNotFound(ObjectId),
14
15 #[error("path `{0}` does not exist")]
17 PathNotFound(VirtualPath),
18
19 #[error("object {0} is not a directory")]
21 NotADirectory(ObjectId),
22
23 #[error("object {0} is not a file")]
25 NotAFile(ObjectId),
26
27 #[error("an object named `{name}` already exists in directory {directory}")]
29 NameAlreadyExists {
30 name: Name,
32 directory: ObjectId,
34 },
35
36 #[error("`{0}` is not a valid object name")]
38 InvalidName(String),
39
40 #[error("`{0}` is not a valid virtual path")]
42 InvalidPath(String),
43
44 #[error("`{0}` is not a valid metadata key")]
46 InvalidMetadataKey(String),
47
48 #[error("object {0} cannot be moved into itself or one of its descendants")]
50 CyclicMove(ObjectId),
51
52 #[error("object {0} cannot be copied into itself or one of its descendants")]
54 CyclicCopy(ObjectId),
55
56 #[error("too many levels of symbolic links: {0}")]
58 SymlinkLoop(String),
59
60 #[error("object {0} is already attached")]
62 AttachedObject(ObjectId),
63
64 #[error("object {0} cannot be attached beneath itself or one of its descendants")]
67 CyclicAttach(ObjectId),
68
69 #[error("the root object cannot be moved")]
71 RootMove,
72
73 #[error("the root object cannot be deleted")]
75 RootDelete,
76
77 #[error("the root object cannot be detached")]
79 RootDetach,
80
81 #[error("Operation not permitted")]
83 NotAuthorized {
84 object: ObjectId,
86 operation: Operation,
88 actor: Option<ActorId>,
90 },
91}