-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create error.rs and Add Basic Errors
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use reqwest::{ Error as ReqwestError, StatusCode }; | ||
use serde_json::Error as SerdeError; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum HeliusError { | ||
#[error("Bad request to {path}: {text}")] | ||
BadRequest { path: String, text: String }, | ||
|
||
#[error("Internal server error: {code} - {text}")] | ||
InternalError { code: StatusCode, text: String}, | ||
|
||
#[error("Too many requests made to {path}")] | ||
TooManyRequests { path: String }, | ||
|
||
#[error("Unauthorized access to {path}: {text}")] | ||
Unauthorized { path: String, text: String }, | ||
|
||
#[error("Unknown error has occurred: HTTP {code} - {text}")] | ||
Unknown { code: StatusCode, text: String }, | ||
} | ||
|
||
|
||
// Handy type alias | ||
pub type Result<T> = std::result::Result<T, HeliusError>; |