mirror of
https://github.com/danbulant/robotparser-rs
synced 2026-05-22 22:09:06 +00:00
* Add test when url is invalid and panic * Initial error handling ref https://github.com/messense/robotparser-rs/issues/22 * Rename ErrorKind::HttpClient => ErrorKind::Http * Implement std::error::Error and rename to Error
23 lines
445 B
Rust
23 lines
445 B
Rust
use std::fmt;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Error {
|
|
pub kind: ErrorKind,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum ErrorKind {
|
|
Url(url::ParseError),
|
|
Http(reqwest::Error),
|
|
}
|
|
|
|
impl fmt::Display for Error {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match self.kind {
|
|
ErrorKind::Url(ref err) => err.fmt(f),
|
|
ErrorKind::Http(ref err) => err.fmt(f),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for Error {}
|