-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
11 additions
and
55 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 |
---|---|---|
@@ -1,47 +1,3 @@ | ||
use crate::message::Messages; | ||
use std::{error, fmt}; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Clone, Debug)] | ||
pub enum RequestError { | ||
#[error("Invalid header (expected {expected:?}, got {found:?})")] | ||
InvalidHeader { expected: String, found: String }, | ||
#[error("Malform Request: {0}")] | ||
MalformedRequest(String), | ||
|
||
#[error("Could not process script: {0}")] | ||
ScriptProcessingError(String), | ||
|
||
#[error("Could not process chain: {0}")] | ||
ChainProcessingError(String), | ||
} | ||
|
||
#[derive(Error, Debug)] | ||
pub struct ConfigError { | ||
pub message: String, | ||
pub source: Option<Box<dyn error::Error + 'static>>, | ||
} | ||
|
||
impl ConfigError { | ||
pub fn new(message: &str) -> Self { | ||
ConfigError { | ||
message: String::from(message), | ||
source: None, | ||
} | ||
} | ||
|
||
pub fn from(error: Box<dyn error::Error + 'static>) -> Self { | ||
ConfigError { | ||
message: error.to_string(), | ||
source: Some(error), | ||
} | ||
} | ||
} | ||
|
||
impl fmt::Display for ConfigError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "An error occured: {:}", self.message) | ||
} | ||
} | ||
|
||
pub type ChainResponse = anyhow::Result<Messages>; |
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
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
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
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
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