-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
944 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
use flatbuffers::InvalidFlatbuffer; | ||
use std::fmt::{Display, Formatter}; | ||
// use flatbuffers::InvalidFlatbuffer; | ||
// use std::fmt::{Display, Formatter}; | ||
|
||
#[derive(Debug)] | ||
pub enum Error { | ||
MissingMagicBytes, | ||
NoIndex, | ||
// #[cfg(feature = "http")] | ||
// HttpClient(http_range_client::HttpError), | ||
IllegalHeaderSize(usize), | ||
InvalidFlatbuffer(InvalidFlatbuffer), | ||
IO(std::io::Error), | ||
} | ||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
impl Display for Error { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Error::MissingMagicBytes => "Missing magic bytes. Is this an fgb file?".fmt(f), | ||
Error::NoIndex => "Index missing".fmt(f), | ||
// #[cfg(feature = "http")] | ||
// Error::HttpClient(http_client) => http_client.fmt(f), | ||
Error::IllegalHeaderSize(size) => write!(f, "Illegal header size: {size}"), | ||
Error::InvalidFlatbuffer(invalid_flatbuffer) => invalid_flatbuffer.fmt(f), | ||
Error::IO(io) => io.fmt(f), | ||
} | ||
} | ||
} | ||
// #[derive(Debug)] | ||
// pub enum Error { | ||
// MissingMagicBytes, | ||
// NoIndex, | ||
// // #[cfg(feature = "http")] | ||
// // HttpClient(http_range_client::HttpError), | ||
// IllegalHeaderSize(usize), | ||
// InvalidFlatbuffer(InvalidFlatbuffer), | ||
// IO(std::io::Error), | ||
// } | ||
// pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
impl std::error::Error for Error {} | ||
// impl Display for Error { | ||
// fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
// match self { | ||
// Error::MissingMagicBytes => "Missing magic bytes. Is this an fgb file?".fmt(f), | ||
// Error::NoIndex => "Index missing".fmt(f), | ||
// // #[cfg(feature = "http")] | ||
// // Error::HttpClient(http_client) => http_client.fmt(f), | ||
// Error::IllegalHeaderSize(size) => write!(f, "Illegal header size: {size}"), | ||
// Error::InvalidFlatbuffer(invalid_flatbuffer) => invalid_flatbuffer.fmt(f), | ||
// Error::IO(io) => io.fmt(f), | ||
// } | ||
// } | ||
// } | ||
|
||
impl From<std::io::Error> for Error { | ||
fn from(value: std::io::Error) -> Self { | ||
Self::IO(value) | ||
} | ||
} | ||
// impl std::error::Error for Error {} | ||
|
||
impl From<InvalidFlatbuffer> for Error { | ||
fn from(value: InvalidFlatbuffer) -> Self { | ||
Error::InvalidFlatbuffer(value) | ||
} | ||
} | ||
// impl From<std::io::Error> for Error { | ||
// fn from(value: std::io::Error) -> Self { | ||
// Self::IO(value) | ||
// } | ||
// } | ||
|
||
// #[cfg(feature = "http")] | ||
// impl From<http_range_client::HttpError> for Error { | ||
// fn from(value: http_range_client::HttpError) -> Self { | ||
// Error::HttpClient(value) | ||
// impl From<InvalidFlatbuffer> for Error { | ||
// fn from(value: InvalidFlatbuffer) -> Self { | ||
// Error::InvalidFlatbuffer(value) | ||
// } | ||
// } | ||
|
||
#[derive(Debug)] | ||
pub enum CityJSONError { | ||
MissingField(&'static str), | ||
// ParseError(String), | ||
// InvalidData(&'static str), | ||
} | ||
impl std::error::Error for CityJSONError {} | ||
// // #[cfg(feature = "http")] | ||
// // impl From<http_range_client::HttpError> for Error { | ||
// // fn from(value: http_range_client::HttpError) -> Self { | ||
// // Error::HttpClient(value) | ||
// // } | ||
// // } | ||
|
||
// #[derive(Debug)] | ||
// pub enum CityJSONError { | ||
// MissingField(&'static str), | ||
// // ParseError(String), | ||
// // InvalidData(&'static str), | ||
// } | ||
// impl std::error::Error for CityJSONError {} | ||
|
||
impl std::fmt::Display for CityJSONError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
CityJSONError::MissingField(field) => write!(f, "Missing field: {}", field), | ||
// CityJSONError::ParseError(err) => write!(f, "Parse error: {}", err), | ||
// CityJSONError::InvalidData(msg) => write!(f, "Invalid data: {}", msg), | ||
} | ||
} | ||
} | ||
// impl std::fmt::Display for CityJSONError { | ||
// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
// match self { | ||
// CityJSONError::MissingField(field) => write!(f, "Missing field: {}", field), | ||
// // CityJSONError::ParseError(err) => write!(f, "Parse error: {}", err), | ||
// // CityJSONError::InvalidData(msg) => write!(f, "Invalid data: {}", msg), | ||
// } | ||
// } | ||
// } |
Oops, something went wrong.