switch to miette for error reporting

This commit is contained in:
Robin Appelman 2021-08-29 20:30:35 +02:00
commit 097ed69b9e
9 changed files with 387 additions and 316 deletions

View file

@ -1,3 +1,4 @@
use miette::DiagnosticResult;
use php_literal_parser::{from_str, ParseError};
use serde_derive::Deserialize;
@ -7,7 +8,7 @@ struct Target {
bars: Vec<u8>,
}
fn main() -> Result<(), ParseError> {
fn main() -> DiagnosticResult<()> {
let target = from_str(r#"["foo" => true, "bars" => [1, 2, 3, 4,]]"#)?;
assert_eq!(

View file

@ -1,6 +1,7 @@
use miette::DiagnosticResult;
use php_literal_parser::{from_str, Value};
fn main() {
fn main() -> DiagnosticResult<()> {
let source = r###"
array (
"double" => "quote",
@ -17,8 +18,6 @@ fn main() {
)
"###;
match from_str::<Value>(source) {
Ok(result) => print!("{:#?}", result),
Err(err) => eprint!("{}", err.with_source(source)),
}
println!("{:#?}", from_str::<Value>(source)?);
Ok(())
}