mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 10:14:10 +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 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();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ pub enum GameEventError {
|
|||
ty: RawEventType,
|
||||
params: String,
|
||||
},
|
||||
#[error("incomplete event body({0:?})")]
|
||||
Incomplete(RawEventType),
|
||||
#[error("truncated event body({0:?})")]
|
||||
Truncated(RawEventType),
|
||||
}
|
||||
|
||||
trait GameEventErrTrait<T> {
|
||||
|
|
|
|||
16
src/lib.rs
16
src/lib.rs
|
|
@ -32,9 +32,21 @@ pub enum Error {
|
|||
#[error("Line should be skipped")]
|
||||
Skip,
|
||||
#[error("Malformed subject: {0}")]
|
||||
Subject(#[from] SubjectError),
|
||||
Subject(Box<SubjectError>),
|
||||
#[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 {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ impl<'a> RawEvent<'a> {
|
|||
}
|
||||
|
||||
fn event_parser(input: &str) -> Result<RawEvent> {
|
||||
// println!("{}", input);
|
||||
if input.len() < 24 {
|
||||
return Err(Error::Skip);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue