youtube_dl_parser/state/
parsed_error_state.rs

1/// Occurs when there's an error reading and the reader ends unexpectedly
2pub struct ParsedErrorState {
3    pub error: String,
4    pub exit_code: u32,
5}
6
7impl ParsedErrorState {
8    pub fn parse(error: String) -> Self {
9        let mut split = error.split(' ').filter(|string| !string.is_empty());
10        let exit_code = split
11            .next_back()
12            .and_then(|exit_code| exit_code.parse::<u32>().ok())
13            .unwrap_or(1);
14        Self { error, exit_code }
15    }
16}