-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mshrtsr/develop
version 0.3.0
- Loading branch information
Showing
4 changed files
with
23 additions
and
75 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
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,14 @@ | ||
use failure::{Backtrace, Context, Fail}; | ||
use std::fmt; | ||
use std::fmt::Display; | ||
use thiserror::Error; | ||
|
||
#[derive(Debug)] | ||
pub struct Error { | ||
inner: Context<ErrorKind>, | ||
} | ||
|
||
#[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)] | ||
pub enum ErrorKind { | ||
#[fail(display = "None error")] | ||
//#[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)] | ||
#[derive(Error, Debug, Eq, PartialEq)] | ||
pub enum Error { | ||
#[error("None error")] | ||
Optional, | ||
#[fail(display = "Line Algebra error: Equations have no solutions")] | ||
#[error("Line Algebra error: Equations have no solutions")] | ||
LinalgSolveNoSolutions, | ||
#[fail(display = "Line Algebra error: Equations have infinite solutions")] | ||
#[error("Line Algebra error: Equations have infinite solutions")] | ||
LinalgSolveInfSolutions, | ||
#[fail(display = "Fitting error")] | ||
#[error("Fitting error")] | ||
Fitting, | ||
} | ||
|
||
impl Fail for Error { | ||
fn cause(&self) -> Option<&dyn Fail> { | ||
self.inner.cause() | ||
} | ||
|
||
fn backtrace(&self) -> Option<&Backtrace> { | ||
self.inner.backtrace() | ||
} | ||
} | ||
|
||
impl Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
Display::fmt(&self.inner, f) | ||
} | ||
} | ||
|
||
impl Error { | ||
pub fn new(inner: Context<ErrorKind>) -> Error { | ||
Error { inner } | ||
} | ||
|
||
pub fn kind(&self) -> &ErrorKind { | ||
self.inner.get_context() | ||
} | ||
} | ||
|
||
impl From<ErrorKind> for Error { | ||
fn from(kind: ErrorKind) -> Error { | ||
Error { | ||
inner: Context::new(kind), | ||
} | ||
} | ||
} | ||
|
||
impl From<Context<ErrorKind>> for Error { | ||
fn from(inner: Context<ErrorKind>) -> Error { | ||
Error { inner } | ||
} | ||
} |
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