Skip to content

Commit

Permalink
Create error.rs and Add Basic Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIchigo committed Apr 17, 2024
1 parent 0c74272 commit b5af6ef
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/error.rs
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>;

0 comments on commit b5af6ef

Please sign in to comment.