taple_core/api/
error.rs

1//! Errors that may occur when interacting with a TAPLE node through its API
2
3pub use crate::protocol::errors::EventCreationError;
4use crate::{approval::error::ApprovalErrorResponse, event::errors::EventError};
5use thiserror::Error;
6
7#[derive(Error, Debug)]
8#[allow(dead_code)]
9pub(crate) enum APIInternalError {
10    #[error("Channel unavailable")]
11    ChannelError,
12    #[error("Oneshot channel not available")]
13    OneshotUnavailable,
14    #[error("An error has ocurred during sign process")]
15    SignError,
16    #[error("Unexpect response received after manager request")]
17    UnexpectedManagerResponse,
18    #[error("Database error {0}")]
19    DatabaseError(String),
20}
21
22/// Errors that may occur when using the TAPLE API
23#[derive(Error, Debug, Clone)]
24pub enum ApiError {
25    #[error("{}", source)]
26    EventCreationError {
27        #[from]
28        source: EventError,
29    },
30    // OLD
31    /// An item of the protocol has not been found, for example, a subject
32    #[error("{0} not found")]
33    NotFound(String),
34    /// An unexpected error has occurred
35    #[error("Unexpected Response")]
36    UnexpectedError,
37    /// An error has occurred in the process of creating an event.
38    // #[error("{}", source)]
39    // EventCreationError {
40    //     #[from]
41    //     source: EventCreationError,
42    // },
43    /// An internal error has occurred
44    #[error("An error has ocurred during approval execution. {}", source)]
45    ApprovalInternalError {
46        #[from]
47        source: ApprovalErrorResponse,
48    },
49    /// Invalid parameters have been entered, usually identifiers.
50    #[error("Invalid parameters: {0}")]
51    InvalidParameters(String),
52    /// An error occurred during a signature process
53    #[error("Sign Process Failed")]
54    SignError,
55    /// No permissions required or possessed to vote on an event request.
56    #[error("Vote not needed for request {0}")]
57    VoteNotNeeded(String),
58    #[error("Not enough permissions. {0}")]
59    NotEnoughPermissions(String),
60    #[error("A database error has ocurred at API module: {0}")]
61    DatabaseError(String),
62    #[error("Conflict: {0}")]
63    Conflict(String),
64}