1use iroh_docs::NamespaceId;
2use miette::Diagnostic;
3use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Error, Debug, Diagnostic)]
7pub enum OkuFsError {
9 #[error("File system entry not found.")]
10 #[diagnostic(
11 code(fs::fs_entry_not_found),
12 url(docsrs),
13 help("Please ensure that the file system entry exists before attempting to read it.")
14 )]
15 FsEntryNotFound,
17 #[error("Author cannot be created.")]
18 #[diagnostic(code(fs::author_cannot_be_created), url(docsrs))]
19 AuthorCannotBeCreated,
21 #[error("Cannot retrieve default author.")]
22 #[diagnostic(code(fs::cannot_retrieve_default_author), url(docsrs))]
23 CannotRetrieveDefaultAuthor,
25 #[error("Cannot start node.")]
26 #[diagnostic(code(fs::cannot_start_node), url(docsrs))]
27 CannotStartNode,
29 #[error("Cannot retrieve list of authors.")]
30 #[diagnostic(code(fs::cannot_retrieve_authors), url(docsrs))]
31 CannotRetrieveAuthors,
33 #[error("Cannot retrieve node address.")]
34 #[diagnostic(code(fs::cannot_retrieve_node_address), url(docsrs))]
35 CannotRetrieveNodeAddress,
37 #[error("Cannot stop node.")]
38 #[diagnostic(code(fs::cannot_stop_node), url(docsrs))]
39 CannotStopNode,
41 #[error("Cannot create replica.")]
42 #[diagnostic(code(fs::cannot_create_replica), url(docsrs))]
43 CannotCreateReplica,
45 #[error("Cannot exit replica.")]
46 #[diagnostic(code(fs::cannot_exit_replica), url(docsrs))]
47 CannotExitReplica,
49 #[error("Cannot delete replica.")]
50 #[diagnostic(code(fs::cannot_delete_replica), url(docsrs))]
51 CannotDeleteReplica,
53 #[error("Cannot list replicas.")]
54 #[diagnostic(code(fs::cannot_list_replicas), url(docsrs))]
55 CannotListReplicas,
57 #[error("Cannot open replica.")]
58 #[diagnostic(code(fs::cannot_open_replica), url(docsrs))]
59 CannotOpenReplica,
61 #[error("Cannot list files.")]
62 #[diagnostic(code(fs::cannot_list_files), url(docsrs))]
63 CannotListFiles,
65 #[error("Cannot create or modify file.")]
66 #[diagnostic(code(fs::cannot_create_or_modify_file), url(docsrs))]
67 CannotCreateOrModifyFile,
69 #[error("Cannot delete file.")]
70 #[diagnostic(code(fs::cannot_delete_file), url(docsrs))]
71 CannotDeleteFile,
73 #[error("Cannot read file.")]
74 #[diagnostic(code(fs::cannot_read_file), url(docsrs))]
75 CannotReadFile,
77 #[error("Cannot delete directory.")]
78 #[diagnostic(code(fs::cannot_delete_directory), url(docsrs))]
79 CannotDeleteDirectory,
81 #[error("Cannot share replica as writable when it is read-only ({0}).")]
82 #[diagnostic(code(fs::cannot_share_replica_writable), url(docsrs))]
83 CannotShareReplicaWritable(NamespaceId),
85}
86
87#[derive(Error, Debug, Diagnostic)]
88pub enum OkuDiscoveryError {
90 #[error("Problem announcing {0} ({1}).")]
91 #[diagnostic(code(discovery::problem_announcing_content), url(docsrs))]
92 ProblemAnnouncingContent(String, String),
94 #[error("Cannot generate sharing ticket for replica.")]
95 #[diagnostic(code(discovery::cannot_generate_sharing_ticket), url(docsrs))]
96 CannotGenerateSharingTicket,
98}
99
100#[derive(Error, Debug, Diagnostic)]
101pub enum OkuFuseError {
103 #[error("No root in path.")]
104 #[diagnostic(code(fuse::no_root), url(docsrs))]
105 NoRoot,
107 #[error("No replica with ID {0:?} found locally.")]
108 #[diagnostic(code(fuse::no_replica), url(docsrs))]
109 NoReplica(String),
111 #[error("No file at path {0:?}.")]
112 #[diagnostic(code(fuse::no_file_at_path), url(docsrs))]
113 NoFileAtPath(PathBuf),
115 #[error("Could not update filesystem handles.")]
116 #[diagnostic(code(fuse::fs_handles_failed_update), url(docsrs))]
117 FsHandlesFailedUpdate,
119 #[error("No file with handle {0}.")]
120 #[diagnostic(code(fuse::no_file_with_handle), url(docsrs))]
121 NoFileWithHandle(u64),
123}