-
Notifications
You must be signed in to change notification settings - Fork 0
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
19 changed files
with
391 additions
and
456 deletions.
There are no files selected for viewing
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,27 @@ | ||
use std::error::Error; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use thiserror::Error; | ||
|
||
// TODO: wrap box error instead | ||
|
||
/// Unrecoverable failure duration [`TaskHandler`] execution. | ||
/// | ||
/// [`TaskHandler`]: crate::handler::TaskHandler | ||
#[derive(Debug, Error, Serialize, Deserialize)] | ||
#[derive(Debug, thiserror::Error)] | ||
#[error("internal handler error")] | ||
#[must_use = "errors do nothing unless you use them"] | ||
#[error("failure during `TaskHandler` execution")] | ||
pub struct TaskError { | ||
name: String, | ||
message: String, | ||
inner: Box<dyn Error>, | ||
} | ||
|
||
impl TaskError { | ||
/// Returns a new [`TaskError`]. | ||
pub fn new() -> Self { | ||
#[inline] | ||
pub fn new<E>(inner: E) -> Self | ||
where | ||
E: Error + 'static, | ||
{ | ||
Self { | ||
name: "".to_owned(), | ||
message: "".to_owned(), | ||
inner: Box::new(inner), | ||
} | ||
} | ||
|
||
/// Returns the underlying error's name. | ||
#[inline] | ||
pub fn name(&self) -> &str { | ||
&self.name | ||
} | ||
|
||
/// Returns the underlying error's message. | ||
#[inline] | ||
pub fn message(&self) -> &str { | ||
&self.message | ||
} | ||
} | ||
|
||
impl From<Box<dyn Error>> for TaskError { | ||
fn from(value: Box<dyn Error>) -> Self { | ||
todo!() | ||
} | ||
} | ||
|
||
/// Specialized [`Result`] alias for the [`TaskError`] type. | ||
pub type TaskResult<T, E = TaskError> = Result<T, E>; | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use crate::context::TaskError; | ||
use crate::Result; | ||
|
||
#[test] | ||
fn instance() -> Result<()> { | ||
let _ = TaskError::new(); | ||
Ok(()) | ||
} | ||
} |
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
Oops, something went wrong.