summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2026-06-11 11:35:24 -0700
committerMike Buland <mike@xagasoft.com>2026-06-11 11:35:24 -0700
commitcffacc4dc4a46b525250772e87fd69a2f1c64dc2 (patch)
tree37ef3b84667668540bdb2bc64576f7eee9bc9c3c /src/error.rs
parent92dbff3cda66a2a677f0c2306bb8508c64884445 (diff)
downloadcrimtag-cffacc4dc4a46b525250772e87fd69a2f1c64dc2.tar.gz
crimtag-cffacc4dc4a46b525250772e87fd69a2f1c64dc2.tar.bz2
crimtag-cffacc4dc4a46b525250772e87fd69a2f1c64dc2.tar.xz
crimtag-cffacc4dc4a46b525250772e87fd69a2f1c64dc2.zip
Split things out, made things easier to use.
CrimError now has several constructors for different cases, so it's easier to use, using constructors is normalized now. Value has a load of From implementations now so it's much, much, much easier to use in practice.
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/error.rs b/src/error.rs
index a2b6d96..a2349ee 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -11,15 +11,22 @@ pub struct CrimError {
11} 11}
12 12
13impl CrimError { 13impl CrimError {
14 pub fn new( position: Position, what: String ) -> Self { 14 pub fn parse( position: Position, what: String ) -> Self {
15 CrimError { 15 Self {
16 position, 16 position,
17 what, 17 what,
18 } 18 }
19 } 19 }
20 20
21 pub fn other(what: String) -> Self {
22 Self {
23 position: Position::none(),
24 what,
25 }
26 }
27
21 pub fn eos( context: &str ) -> Self { 28 pub fn eos( context: &str ) -> Self {
22 CrimError { 29 Self {
23 position: Position::none(), 30 position: Position::none(),
24 what: format!("Premature end of stream while looking for {}", context), 31 what: format!("Premature end of stream while looking for {}", context),
25 } 32 }