oku_fs/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
use iroh::docs::NamespaceId;
use miette::Diagnostic;
use std::path::PathBuf;
use thiserror::Error;

#[derive(Error, Debug, Diagnostic)]
/// File system errors.
pub enum OkuFsError {
    #[error("File system entry not found.")]
    #[diagnostic(
        code(fs::fs_entry_not_found),
        url(docsrs),
        help("Please ensure that the file system entry exists before attempting to read it.")
    )]
    /// File system entry not found.
    FsEntryNotFound,
    #[error("Author cannot be created.")]
    #[diagnostic(code(fs::author_cannot_be_created), url(docsrs))]
    /// Author cannot be created.
    AuthorCannotBeCreated,
    #[error("Cannot retrieve default author.")]
    #[diagnostic(code(fs::cannot_retrieve_default_author), url(docsrs))]
    /// Cannot retrieve default author.
    CannotRetrieveDefaultAuthor,
    #[error("Cannot start node.")]
    #[diagnostic(code(fs::cannot_start_node), url(docsrs))]
    /// Cannot start node.
    CannotStartNode,
    #[error("Cannot retrieve list of authors.")]
    #[diagnostic(code(fs::cannot_retrieve_authors), url(docsrs))]
    /// Cannot retrieve list of authors.
    CannotRetrieveAuthors,
    #[error("Cannot retrieve node address.")]
    #[diagnostic(code(fs::cannot_retrieve_node_address), url(docsrs))]
    /// Cannot retrieve node address.
    CannotRetrieveNodeAddress,
    #[error("Cannot stop node.")]
    #[diagnostic(code(fs::cannot_stop_node), url(docsrs))]
    /// Cannot stop node.
    CannotStopNode,
    #[error("Cannot create replica.")]
    #[diagnostic(code(fs::cannot_create_replica), url(docsrs))]
    /// Cannot create replica.
    CannotCreateReplica,
    #[error("Cannot exit replica.")]
    #[diagnostic(code(fs::cannot_exit_replica), url(docsrs))]
    /// Cannot exit replica.
    CannotExitReplica,
    #[error("Cannot delete replica.")]
    #[diagnostic(code(fs::cannot_delete_replica), url(docsrs))]
    /// Cannot delete replica.
    CannotDeleteReplica,
    #[error("Cannot list replicas.")]
    #[diagnostic(code(fs::cannot_list_replicas), url(docsrs))]
    /// Cannot list replicas.
    CannotListReplicas,
    #[error("Cannot open replica.")]
    #[diagnostic(code(fs::cannot_open_replica), url(docsrs))]
    /// Cannot open replica.
    CannotOpenReplica,
    #[error("Cannot list files.")]
    #[diagnostic(code(fs::cannot_list_files), url(docsrs))]
    /// Cannot list files.
    CannotListFiles,
    #[error("Cannot create or modify file.")]
    #[diagnostic(code(fs::cannot_create_or_modify_file), url(docsrs))]
    /// Cannot create or modify file.
    CannotCreateOrModifyFile,
    #[error("Cannot delete file.")]
    #[diagnostic(code(fs::cannot_delete_file), url(docsrs))]
    /// Cannot delete file.
    CannotDeleteFile,
    #[error("Cannot read file.")]
    #[diagnostic(code(fs::cannot_read_file), url(docsrs))]
    /// Cannot read file.
    CannotReadFile,
    #[error("Cannot delete directory.")]
    #[diagnostic(code(fs::cannot_delete_directory), url(docsrs))]
    /// Cannot delete directory.
    CannotDeleteDirectory,
    #[error("Cannot share replica as writable when it is read-only ({0}).")]
    #[diagnostic(code(fs::cannot_share_replica_writable), url(docsrs))]
    /// Cannot delete directory.
    CannotShareReplicaWritable(NamespaceId),
}

#[derive(Error, Debug, Diagnostic)]
/// Content discovery errors.
pub enum OkuDiscoveryError {
    #[error("Problem announcing {0} ({1}).")]
    #[diagnostic(code(discovery::problem_announcing_content), url(docsrs))]
    /// Problem announcing content.
    ProblemAnnouncingContent(String, String),
    #[error("Cannot generate sharing ticket for replica.")]
    #[diagnostic(code(discovery::cannot_generate_sharing_ticket), url(docsrs))]
    /// Cannot generate sharing ticket for replica.
    CannotGenerateSharingTicket,
}

#[derive(Error, Debug, Diagnostic)]
/// FUSE errors.
pub enum OkuFuseError {
    #[error("No root in path.")]
    #[diagnostic(code(fuse::no_root), url(docsrs))]
    /// No root in path.
    NoRoot,
    #[error("No replica with ID {0:?} found locally.")]
    #[diagnostic(code(fuse::no_replica), url(docsrs))]
    /// No replica with ID found locally.
    NoReplica(String),
    #[error("No file at path {0:?}.")]
    #[diagnostic(code(fuse::no_file_at_path), url(docsrs))]
    /// No file at path.
    NoFileAtPath(PathBuf),
    #[error("Could not update filesystem handles.")]
    #[diagnostic(code(fuse::fs_handles_failed_update), url(docsrs))]
    /// Could not update filesystem handles.
    FsHandlesFailedUpdate,
    #[error("No file with handle {0}.")]
    #[diagnostic(code(fuse::no_file_with_handle), url(docsrs))]
    /// No file with handle.
    NoFileWithHandle(u64),
}