#[non_exhaustive]pub enum EstatError {
Connection(Error),
JsonParse(Error),
Api {
status: u16,
message: String,
},
HttpStatus(u16, String),
UnexpectedResponse(String),
InvalidArgument(String),
}Expand description
Error type returned by all API calls.
e-Stat reports errors in the RESULT element of the body, with a status
of 100 or more. Api holds that status, not the HTTP status.
§Example
use estat_api::EstatError;
let error = EstatError::Api { status: 100, message: "認証に失敗しました。".into() };
assert!(error.is_unauthorized());
assert_eq!(error.status(), Some(100));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Connection(Error)
Failed to connect, send the request, or read the response body.
The request URL is removed from the error because it contains the application ID.
JsonParse(Error)
The response body is not the expected JSON.
Api
e-Stat returned an error in RESULT.
100 invalid application ID, 101 to 105 invalid parameters,
200 to 299 server errors, 300 no table or dataset with that ID,
301 and 302 refused dataset changes, 400 and 401 failed bulk requests.
Fields
HttpStatus(u16, String)
The server answered with an HTTP error status and a body that is not an e-Stat response, such as a maintenance page. Holds the HTTP status and the body.
UnexpectedResponse(String)
The body is JSON but not shaped like an e-Stat response, or paging did not move forward.
InvalidArgument(String)
The request was rejected before sending.
Implementations§
Source§impl EstatError
impl EstatError
Sourcepub fn status(&self) -> Option<u16>
pub fn status(&self) -> Option<u16>
Status of Api (RESULT.STATUS) or
HttpStatus (HTTP status), None otherwise.
true for status 100: the application ID is wrong.
Sourcepub fn is_invalid_parameter(&self) -> bool
pub fn is_invalid_parameter(&self) -> bool
true for status 101 to 105: a parameter is missing or invalid.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
true for status 300: no table or dataset with the given ID.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
true for status 200 to 299: a temporary error on the e-Stat side.
The manual asks to wait before trying again.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
true when the request timed out.
Trait Implementations§
Source§impl Debug for EstatError
impl Debug for EstatError
Source§impl Display for EstatError
impl Display for EstatError
Source§impl Error for EstatError
impl Error for EstatError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()