| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# as StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#}; |
| 3 | |
| 4 | /// An error in the API. |
| 5 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 6 | pub enum Errorrust-analyzer cargo railway-core 0.3.0 error/Error#<R, P> { |
| 7 | /// Error requesting data using the [`Requester`](crate::Requester). |
| 8 | Requestrust-analyzer cargo railway-core 0.3.0 error/Error#Request#(R), |
| 9 | /// Any [`Provider`](crate::Provider)-specific error, e.g. failing to parse the response from the API. |
| 10 | Providerrust-analyzer cargo railway-core 0.3.0 error/Error#Provider#(P), // TODO: Journey not found, ... |
| 11 | /// Provider doesn't have implementation for this specific feature |
| 12 | NotImplementedrust-analyzer cargo railway-core 0.3.0 error/Error#NotImplemented#, |
| 13 | } |
| 14 | |
| 15 | impl<R: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, P: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#> Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Errorrust-analyzer cargo railway-core 0.3.0 error/Error#<R, P> { |
| 16 | fn fmtrust-analyzer cargo railway-core 0.3.0 error/impl#[`Error<R, P>`][Display]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> { |
| 17 | match self { |
| 18 | Selfrust-analyzer cargo railway-core 0.3.0 error/impl#[`Error<R, P>`][Display]::Requestrust-analyzer cargo railway-core 0.3.0 error/Error#Request#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "error requesting data: {}", e), |
| 19 | Selfrust-analyzer cargo railway-core 0.3.0 error/impl#[`Error<R, P>`][Display]::Providerrust-analyzer cargo railway-core 0.3.0 error/Error#Provider#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "provider specific error: {}", e), |
| 20 | Selfrust-analyzer cargo railway-core 0.3.0 error/impl#[`Error<R, P>`][Display]::NotImplementedrust-analyzer cargo railway-core 0.3.0 error/Error#NotImplemented# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "not implemented by this provider"), |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | impl<R: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#, P: StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#> StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for Errorrust-analyzer cargo railway-core 0.3.0 error/Error#<R, P> {} |