Commit 994a8f7c authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

Merge branch 'errors-for-dirprovider' into 'main'

Errors for dirprovider

Closes #370

See merge request !385
parents b0952652 055b7399
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -91,6 +91,17 @@ pub enum Error {
        cause: Arc<SpawnError>,
    },

    /// Other error from an external directory provider
    #[error("external directory provider")]
    ExternalDirProvider {
        /// What happened
        #[source]
        cause: Arc<dyn std::error::Error + Send + Sync + 'static>,

        /// The kind
        kind: ErrorKind,
    },

    /// A programming problem, either in our code or the code calling it.
    #[error("programming problem: {0}")]
    Bug(#[from] tor_error::Bug),
@@ -168,6 +179,7 @@ impl HasKind for Error {
            E::IOError(_) => EK::CacheAccessFailed,
            E::OfflineMode => EK::BadApiUsage,
            E::Spawn { cause, .. } => cause.kind(),
            E::ExternalDirProvider { kind, .. } => *kind,
            E::Bug(e) => e.kind(),
        }
    }
+10 −0
Original line number Diff line number Diff line
@@ -532,6 +532,16 @@ pub enum ErrorKind {
    /// our [bug tracker](https://gitlab.torproject.org/tpo/core/arti/-/issues).
    #[display(fmt = "internal error (bug)")]
    Internal,

    /// Unclassified error
    ///
    /// Some other error occurred, which does not fit into any of the other kinds.
    ///
    /// This kind is provided for use by external code
    /// hooking into or replacing parts of Arti.
    /// It is never returned by the code in Arti (`arti-*` and `tor-*` crates).
    #[display(fmt = "unclassified error")]
    Other,
}

/// Errors that can be categorized as belonging to an [`ErrorKind`]