mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
box sub error types
This commit is contained in:
parent
b01029ddde
commit
a90cb67dc2
4 changed files with 18 additions and 5 deletions
|
|
@ -19,7 +19,7 @@ fn main() -> Result<(), MainError> {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
let style = ProgressStyle::with_template(
|
let style = ProgressStyle::with_template(
|
||||||
"[{elapsed_precise}] {wide_bar:.cyan/blue} {per_sec:!} {pos:>7}/{len:7}",
|
"[{elapsed_precise}] {wide_bar:.cyan/blue} {per_sec:!} {pos:>7}/{len:7} [{eta}]",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ pub enum GameEventError {
|
||||||
ty: RawEventType,
|
ty: RawEventType,
|
||||||
params: String,
|
params: String,
|
||||||
},
|
},
|
||||||
#[error("incomplete event body({0:?})")]
|
#[error("truncated event body({0:?})")]
|
||||||
Incomplete(RawEventType),
|
Truncated(RawEventType),
|
||||||
}
|
}
|
||||||
|
|
||||||
trait GameEventErrTrait<T> {
|
trait GameEventErrTrait<T> {
|
||||||
|
|
|
||||||
16
src/lib.rs
16
src/lib.rs
|
|
@ -32,9 +32,21 @@ pub enum Error {
|
||||||
#[error("Line should be skipped")]
|
#[error("Line should be skipped")]
|
||||||
Skip,
|
Skip,
|
||||||
#[error("Malformed subject: {0}")]
|
#[error("Malformed subject: {0}")]
|
||||||
Subject(#[from] SubjectError),
|
Subject(Box<SubjectError>),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
MalformedEvent(#[from] GameEventError),
|
MalformedEvent(Box<GameEventError>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<SubjectError> for Error {
|
||||||
|
fn from(value: SubjectError) -> Self {
|
||||||
|
Error::Subject(Box::new(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<GameEventError> for Error {
|
||||||
|
fn from(value: GameEventError) -> Self {
|
||||||
|
Error::MalformedEvent(Box::new(value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseIntError> for Error {
|
impl From<ParseIntError> for Error {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ impl<'a> RawEvent<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn event_parser(input: &str) -> Result<RawEvent> {
|
fn event_parser(input: &str) -> Result<RawEvent> {
|
||||||
|
// println!("{}", input);
|
||||||
if input.len() < 24 {
|
if input.len() < 24 {
|
||||||
return Err(Error::Skip);
|
return Err(Error::Skip);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue