Skip to main content

unkey/
error.rs

1use crate::models::common::ErrorDetail;
2
3/// Errors returned by the Unkey SDK.
4#[derive(Debug, thiserror::Error)]
5pub enum UnkeyError {
6    #[error("bad request: {0}")]
7    BadRequest(ErrorDetail),
8
9    #[error("unauthorized: {0}")]
10    Unauthorized(ErrorDetail),
11
12    #[error("forbidden: {0}")]
13    Forbidden(ErrorDetail),
14
15    #[error("not found: {0}")]
16    NotFound(ErrorDetail),
17
18    #[error("conflict: {0}")]
19    Conflict(ErrorDetail),
20
21    #[error("unprocessable entity: {0}")]
22    UnprocessableEntity(ErrorDetail),
23
24    #[error("too many requests: {0}")]
25    TooManyRequests(ErrorDetail),
26
27    #[error("internal server error: {0}")]
28    InternalServer(ErrorDetail),
29
30    #[error("service unavailable: {0}")]
31    ServiceUnavailable(ErrorDetail),
32
33    #[error("http error: {0}")]
34    Http(#[from] reqwest::Error),
35
36    #[error("deserialization error: {0}")]
37    Deserialize(#[from] serde_json::Error),
38
39    #[error("unexpected status {status}: {detail}")]
40    UnexpectedStatus { status: u16, detail: String },
41}