use iroh::docs::NamespaceId;
use miette::Diagnostic;
use std::path::PathBuf;
use thiserror::Error;
#[derive(Error, Debug, Diagnostic)]
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.")
)]
FsEntryNotFound,
#[error("Author cannot be created.")]
#[diagnostic(code(fs::author_cannot_be_created), url(docsrs))]
AuthorCannotBeCreated,
#[error("Cannot retrieve default author.")]
#[diagnostic(code(fs::cannot_retrieve_default_author), url(docsrs))]
CannotRetrieveDefaultAuthor,
#[error("Cannot start node.")]
#[diagnostic(code(fs::cannot_start_node), url(docsrs))]
CannotStartNode,
#[error("Cannot retrieve list of authors.")]
#[diagnostic(code(fs::cannot_retrieve_authors), url(docsrs))]
CannotRetrieveAuthors,
#[error("Cannot retrieve node address.")]
#[diagnostic(code(fs::cannot_retrieve_node_address), url(docsrs))]
CannotRetrieveNodeAddress,
#[error("Cannot stop node.")]
#[diagnostic(code(fs::cannot_stop_node), url(docsrs))]
CannotStopNode,
#[error("Cannot create replica.")]
#[diagnostic(code(fs::cannot_create_replica), url(docsrs))]
CannotCreateReplica,
#[error("Cannot exit replica.")]
#[diagnostic(code(fs::cannot_exit_replica), url(docsrs))]
CannotExitReplica,
#[error("Cannot delete replica.")]
#[diagnostic(code(fs::cannot_delete_replica), url(docsrs))]
CannotDeleteReplica,
#[error("Cannot list replicas.")]
#[diagnostic(code(fs::cannot_list_replicas), url(docsrs))]
CannotListReplicas,
#[error("Cannot open replica.")]
#[diagnostic(code(fs::cannot_open_replica), url(docsrs))]
CannotOpenReplica,
#[error("Cannot list files.")]
#[diagnostic(code(fs::cannot_list_files), url(docsrs))]
CannotListFiles,
#[error("Cannot create or modify file.")]
#[diagnostic(code(fs::cannot_create_or_modify_file), url(docsrs))]
CannotCreateOrModifyFile,
#[error("Cannot delete file.")]
#[diagnostic(code(fs::cannot_delete_file), url(docsrs))]
CannotDeleteFile,
#[error("Cannot read file.")]
#[diagnostic(code(fs::cannot_read_file), url(docsrs))]
CannotReadFile,
#[error("Cannot delete directory.")]
#[diagnostic(code(fs::cannot_delete_directory), url(docsrs))]
CannotDeleteDirectory,
#[error("Cannot share replica as writable when it is read-only ({0}).")]
#[diagnostic(code(fs::cannot_share_replica_writable), url(docsrs))]
CannotShareReplicaWritable(NamespaceId),
}
#[derive(Error, Debug, Diagnostic)]
pub enum OkuDiscoveryError {
#[error("Problem announcing {0} ({1}).")]
#[diagnostic(code(discovery::problem_announcing_content), url(docsrs))]
ProblemAnnouncingContent(String, String),
#[error("Cannot generate sharing ticket for replica.")]
#[diagnostic(code(discovery::cannot_generate_sharing_ticket), url(docsrs))]
CannotGenerateSharingTicket,
}
#[derive(Error, Debug, Diagnostic)]
pub enum OkuFuseError {
#[error("No root in path.")]
#[diagnostic(code(fuse::no_root), url(docsrs))]
NoRoot,
#[error("No replica with ID {0:?} found locally.")]
#[diagnostic(code(fuse::no_replica), url(docsrs))]
NoReplica(String),
#[error("No file at path {0:?}.")]
#[diagnostic(code(fuse::no_file_at_path), url(docsrs))]
NoFileAtPath(PathBuf),
#[error("Could not update filesystem handles.")]
#[diagnostic(code(fuse::fs_handles_failed_update), url(docsrs))]
FsHandlesFailedUpdate,
#[error("No file with handle {0}.")]
#[diagnostic(code(fuse::no_file_with_handle), url(docsrs))]
NoFileWithHandle(u64),
}