thiserror
This commit is contained in:
parent
e92e1e3f7c
commit
f23266f63c
9
Cargo.lock
generated
9
Cargo.lock
generated
|
@ -1416,18 +1416,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.31"
|
version = "1.0.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
|
checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.31"
|
version = "1.0.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
|
checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1738,6 +1738,7 @@ dependencies = [
|
||||||
"logos",
|
"logos",
|
||||||
"ordered-float",
|
"ordered-float",
|
||||||
"rustyline",
|
"rustyline",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -12,3 +12,4 @@ eframe = "*"
|
||||||
logos = "*"
|
logos = "*"
|
||||||
ordered-float = "3.0"
|
ordered-float = "3.0"
|
||||||
rustyline = "10.0"
|
rustyline = "10.0"
|
||||||
|
thiserror = "1.0"
|
||||||
|
|
15
src/error.rs
15
src/error.rs
|
@ -1,10 +1,11 @@
|
||||||
use crate::syntax::lexer::Token;
|
use crate::syntax::lexer::Token;
|
||||||
use ariadne::{Color, Fmt, Label, Report, ReportKind, Source};
|
use ariadne::{Color, Fmt, Label, Report, ReportKind, Source};
|
||||||
use chumsky::error::{Simple, SimpleReason};
|
use chumsky::error::{Simple, SimpleReason};
|
||||||
use std::fmt::Display;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Error, Clone)]
|
||||||
pub enum Error<'a> {
|
pub enum Error<'a> {
|
||||||
|
#[error("parse error: {0:?}")]
|
||||||
Parse(Simple<Token<'a>>),
|
Parse(Simple<Token<'a>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,13 +74,3 @@ impl<'a> Error<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Display for Error<'a> {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
Error::Parse(e) => write!(f, "{e:?}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> std::error::Error for Error<'a> {}
|
|
||||||
|
|
Loading…
Reference in a new issue