diff options
| author | eichlan <eichlan@jotunn.office.penny-arcade.com> | 2026-06-23 15:31:51 -0700 |
|---|---|---|
| committer | eichlan <eichlan@jotunn.office.penny-arcade.com> | 2026-06-23 15:31:51 -0700 |
| commit | 062048ef6e3e060bcf841ea2ec92e026f09d8da0 (patch) | |
| tree | 22f7dad062b16f25fcfa1a28af13ac2937348ef0 /src/error.rs | |
| parent | 7c299c86bbac76ec2ac199d68eb4dda093a64e3a (diff) | |
| download | crimtag-062048ef6e3e060bcf841ea2ec92e026f09d8da0.tar.gz crimtag-062048ef6e3e060bcf841ea2ec92e026f09d8da0.tar.bz2 crimtag-062048ef6e3e060bcf841ea2ec92e026f09d8da0.tar.xz crimtag-062048ef6e3e060bcf841ea2ec92e026f09d8da0.zip | |
Roorganized into workspace and packages.
This is to accomidate a new proc_macro package, which can't have
anything else in it.
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/error.rs b/src/error.rs deleted file mode 100644 index bbb5d6f..0000000 --- a/src/error.rs +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | |||
| 2 | use core::error::Error; | ||
| 3 | use std::fmt; | ||
| 4 | |||
| 5 | use crate::position::*; | ||
| 6 | |||
| 7 | #[derive(Debug)] | ||
| 8 | pub struct CrimError { | ||
| 9 | position: Position, | ||
| 10 | what: String, | ||
| 11 | } | ||
| 12 | |||
| 13 | impl CrimError { | ||
| 14 | pub fn parse( position: Position, what: String ) -> Self { | ||
| 15 | Self { | ||
| 16 | position, | ||
| 17 | what, | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | pub fn other(what: String) -> Self { | ||
| 22 | Self { | ||
| 23 | position: Position::none(), | ||
| 24 | what, | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | pub fn broken( position: Position, what: &str ) -> Self { | ||
| 29 | Self { | ||
| 30 | position, | ||
| 31 | what: format!("Broken parser? {}", what), | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | pub fn eos( context: &str ) -> Self { | ||
| 36 | Self { | ||
| 37 | position: Position::none(), | ||
| 38 | what: format!("Premature end of stream while looking for {}", context), | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | pub fn what(&self) -> &str { | ||
| 43 | &self.what | ||
| 44 | } | ||
| 45 | |||
| 46 | pub fn start(&self) -> &Position { | ||
| 47 | &self.position | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | impl fmt::Display for CrimError { | ||
| 52 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| 53 | write!(f, "Error parsing input: {}", "yeah") | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | impl Error for CrimError { } | ||
| 58 | |||
| 59 | pub type CrimResult<T> = Result<T, CrimError>; | ||
