-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improv: global modeler error type, finer-grained errors, using `thise…
…rror` (#5) * improv: global modeler error type, finer-grained errors, using `thiserror` * fix: public error module * chore: fix typos
- Loading branch information
Showing
12 changed files
with
109 additions
and
65 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 |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
/Cargo.lock | ||
/.vscode | ||
/*.code-workspace | ||
/ink-stroke-modeler/build | ||
/docs/*.pdf | ||
/test | ||
/expand |
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ svg = "0.16.0" | |
tracing = "0.1.40" | ||
|
||
[dependencies] | ||
thiserror = "1.0.61" |
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
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,37 @@ | ||
#[derive(Debug, Clone, thiserror::Error)] | ||
#[non_exhaustive] | ||
pub enum ElementError { | ||
#[error("A duplicate element is sent to the modeler")] | ||
Duplicate, | ||
#[error("A sent element has a time earlier than the previous one")] | ||
NegativeTimeDelta, | ||
#[error("Sent element order is incorrect")] | ||
Order { | ||
#[from] | ||
src: ElementOrderError, | ||
}, | ||
#[error("Sent element's time is too far apart from the previous one")] | ||
TooFarApart, | ||
} | ||
|
||
#[derive(Debug, Clone, thiserror::Error)] | ||
#[non_exhaustive] | ||
#[allow(clippy::enum_variant_names)] | ||
pub enum ElementOrderError { | ||
#[error("Down Event is not the first or occurred after a different event")] | ||
UnexpectedDown, | ||
#[error("Move event occurred before a initial down event")] | ||
UnexpectedMove, | ||
#[error("No other event occurred before an up event")] | ||
UnexpectedUp, | ||
} | ||
|
||
#[derive(Debug, Clone, thiserror::Error)] | ||
#[non_exhaustive] | ||
pub enum ModelerError { | ||
#[error("Input element error")] | ||
Element { | ||
#[from] | ||
src: ElementError, | ||
}, | ||
} |
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,24 +1,20 @@ | ||
// imports | ||
use std::collections::VecDeque; | ||
|
||
#[cfg(test)] | ||
extern crate approx; | ||
|
||
// modules | ||
// Modules | ||
mod engine; | ||
pub mod error; | ||
mod input; | ||
mod params; | ||
mod position_modeler; | ||
mod results; | ||
mod state_modeler; | ||
mod utils; | ||
|
||
pub use engine::Errors; | ||
#[cfg(test)] | ||
extern crate approx; | ||
|
||
// Re-Exports | ||
pub use engine::StrokeModeler; | ||
pub use error::ModelerError; | ||
pub use input::ModelerInput; | ||
pub use input::ModelerInputEventType; | ||
pub use params::ModelerParams; | ||
use position_modeler::PositionModeler; | ||
use results::ModelerPartial; | ||
pub use results::ModelerResult; | ||
use state_modeler::StateModeler; |
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