[][src]Struct interledger_http::error::ApiError

pub struct ApiError {
    pub type: &'static ProblemType,
    pub title: &'static str,
    pub status: StatusCode,
    pub detail: Option<String>,
    pub instance: Option<String>,
    pub extension_members: Option<Map<String, Value>>,
}

This struct represents the fields defined in RFC7807. The meaning of each field could be found at Members of a Problem Details Object section. ApiError implements Reply so that it could be used for responses.

Fields

type: &'static ProblemType

type is a URI which represents an error type. The URI should provide human-readable documents so that developers can solve the problem easily.

title: &'static str

title is a short, human-readable summary of the type. SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.

status: StatusCode

status is a HTTP status of the problem.

detail: Option<String>

detail explains the problem in human-readable detail.

instance: Option<String>

instance is a URI reference that identifies the specific occurrence of the problem. We should be careful of how we provide the URI because if it provides very detailed information about the error, it might expose some vulnerabilities of the node.

extension_members: Option<Map<String, Value>>

extension_members is a Map of JSON values which will be flatly injected into response JSONs. For example, if we specify extension_members like:

"invalid-params": [
    { "name": "Username", "type": "missing" }
]

then this map is merged into the response JSON and will look like:

{
    "type": "about:blank",
    "title": "Missing Fields Error",
    "status": 400,
    "detail": "foo bar",
    "invalid-params": [
        { "name": "Username", "type": "missing" }
    ]
}

Methods

impl ApiError[src]

pub fn from_api_error_type(problem_type: &ApiErrorType) -> Self[src]

pub fn bad_request() -> Self[src]

pub fn internal_server_error() -> Self[src]

pub fn unauthorized() -> Self[src]

pub fn not_found() -> Self[src]

pub fn method_not_allowed() -> Self[src]

pub fn account_not_found() -> Self[src]

pub fn idempotency_conflict() -> Self[src]

pub fn invalid_account_id(invalid_account_id: Option<&str>) -> Self[src]

pub fn invalid_ilp_packet() -> Self[src]

pub fn detail<T>(self, detail: T) -> Self where
    T: Into<String>, 
[src]

pub fn instance<T>(self, instance: T) -> Self where
    T: Into<String>, 
[src]

pub fn extension_members(
    self,
    extension_members: Option<Map<String, Value>>
) -> Self
[src]

Trait Implementations

impl From<ApiError> for Rejection[src]

impl Clone for ApiError[src]

impl Display for ApiError[src]

impl Debug for ApiError[src]

impl Error for ApiError[src]

impl Serialize for ApiError[src]

impl Reply for ApiError[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<E> Fail for E where
    E: 'static + Error + Send + Sync

impl<T> AsFail for T where
    T: Fail, 

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err