Skip to content

Commit

Permalink
switch to thiserror
Browse files Browse the repository at this point in the history
  • Loading branch information
gdesmott committed Dec 20, 2024
1 parent 7f59d33 commit e1cf9ac
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ itertools = "0.13"
gstreamer = "0.23"
regex = "1.3"
lazy_static = "1.4"
failure = "0.1.8"
thiserror = "2.0"
anyhow = "1"

[[example]]
Expand Down
3 changes: 1 addition & 2 deletions examples/check-latency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

// Generate input logs with: GST_DEBUG="GST_TRACER:7" GST_TRACERS=latency

use failure::Error;
use gst_log_parser::parse;
use gstreamer::{ClockTime, DebugLevel};
use std::fs::File;
Expand Down Expand Up @@ -40,7 +39,7 @@ struct Opt {
command: Command,
}

fn main() -> Result<(), Error> {
fn main() -> Result<(), anyhow::Error> {
let opt = Opt::from_args();
let input = File::open(opt.input)?;

Expand Down
3 changes: 1 addition & 2 deletions examples/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

// Generate input logs with: GST_DEBUG="GST_TRACER:7" GST_TRACERS=stats

use failure::Error;
use gnuplot::*;
use gst_log_parser::parse;
use gstreamer::{ClockTime, DebugLevel, Structure};
Expand Down Expand Up @@ -266,7 +265,7 @@ impl Flow {
}
}

fn main() -> Result<(), Error> {
fn main() -> Result<(), anyhow::Error> {
let opt = Opt::from_args();
let input = File::open(opt.input)?;
let mut flow = Flow::new(opt.command);
Expand Down
3 changes: 1 addition & 2 deletions examples/latency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

// Generate input logs with: GST_DEBUG="GST_TRACER:7" GST_TRACERS=latency\(flags="pipeline+element+reported"\)

use failure::Error;
use gst_log_parser::parse;
use gstreamer::{ClockTime, DebugLevel};
use itertools::Itertools;
Expand Down Expand Up @@ -43,7 +42,7 @@ impl Count {
}
}

fn main() -> Result<(), Error> {
fn main() -> Result<(), anyhow::Error> {
let opt = Opt::from_args();
let input = File::open(opt.input)?;

Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use std::io::Read;
use std::str;
use std::str::FromStr;

use failure::Fail;
use gst::{ClockTime, DebugLevel, Structure};
use gstreamer as gst;
use lazy_static::lazy_static;
use regex::Regex;
use thiserror::Error;

#[derive(Debug, PartialEq)]
pub enum TimestampField {
Expand All @@ -43,19 +43,19 @@ pub enum Token {
Object,
}

#[derive(Debug, Fail, PartialEq)]
#[derive(Debug, Error, PartialEq)]
pub enum ParsingError {
#[fail(display = "invalid debug level: {}", name)]
#[error("invalid debug level: {}", name)]
InvalidDebugLevel { name: String },
#[fail(display = "invalid timestamp: {} : {:?}", ts, field)]
#[error("invalid timestamp: {} : {:?}", ts, field)]
InvalidTimestamp { ts: String, field: TimestampField },
#[fail(display = "missing token: {:?}", t)]
#[error("missing token: {:?}", t)]
MissingToken { t: Token },
#[fail(display = "invalid PID: {}", pid)]
#[error("invalid PID: {}", pid)]
InvalidPID { pid: String },
#[fail(display = "missing location")]
#[error("missing location")]
MissingLocation,
#[fail(display = "invalid line number: {}", line)]
#[error("invalid line number: {}", line)]
InvalidLineNumber { line: String },
}

Expand Down

0 comments on commit e1cf9ac

Please sign in to comment.