Changed unexpectedStatusCode error to use a list of errors instead of a singular one
This commit is contained in:
parent
f6e2bd7272
commit
cc14a34e76
@ -11,7 +11,7 @@ pub enum Error{
|
|||||||
/// Same as UnexpectedStatusCode but without the extra details.
|
/// Same as UnexpectedStatusCode but without the extra details.
|
||||||
ClientError(MessageResource),
|
ClientError(MessageResource),
|
||||||
/// Takes the status code you expected, the actual status code, and the ErrorMessage. This is meant to be used when your app tries to use an API, be it internal or external.
|
/// Takes the status code you expected, the actual status code, and the ErrorMessage. This is meant to be used when your app tries to use an API, be it internal or external.
|
||||||
UnexpectedStatusCode(u16, u16, MessageResource),
|
UnexpectedStatusCode(u16, u16, Vec<MessageResource>),
|
||||||
/// Try and never use this error, unless you really need to.
|
/// Try and never use this error, unless you really need to.
|
||||||
Unspecified,
|
Unspecified,
|
||||||
/// If you had an error serializing/deserializing and wish to display more details. Such as the entire Json as a string, this is how.
|
/// If you had an error serializing/deserializing and wish to display more details. Such as the entire Json as a string, this is how.
|
||||||
@ -27,7 +27,7 @@ impl fmt::Display for Error{
|
|||||||
match *&self {
|
match *&self {
|
||||||
Error::Unspecified => write!(f, "Error of type Unspecified."),
|
Error::Unspecified => write!(f, "Error of type Unspecified."),
|
||||||
Error::NetworkError(message) => write!(f, "Error of type Network.\nMessageResource: {}", message),
|
Error::NetworkError(message) => write!(f, "Error of type Network.\nMessageResource: {}", message),
|
||||||
Error::UnexpectedStatusCode(expected, actual, message) => write!(f, "Error of type UnexpectedStatusCode.\nExpected: {}\nActual: {}\nreceivedMessageResource: {:?}", expected, actual, message),
|
Error::UnexpectedStatusCode(expected, actual, messages) => write!(f, "Error of type UnexpectedStatusCode.\nExpected: {}\nActual: {}\nreceivedMessageResources: {:?}", expected, actual, messages),
|
||||||
Error::ClientError(message) => write!(f, "Error of type Client.\nMessageResource: {}", message),
|
Error::ClientError(message) => write!(f, "Error of type Client.\nMessageResource: {}", message),
|
||||||
Error::SerdeError(message, recieved) => write!(f, "Error of type Serialization/Deserialization.\nMessageResource: {:?}, Object attempted to be serded: {}", message, recieved),
|
Error::SerdeError(message, recieved) => write!(f, "Error of type Serialization/Deserialization.\nMessageResource: {:?}, Object attempted to be serded: {}", message, recieved),
|
||||||
Error::DatabaseError(message, query) => write!(f, "Error of type Database.\nMessageResource: {}, \nQuery: {}", message, query),
|
Error::DatabaseError(message, query) => write!(f, "Error of type Database.\nMessageResource: {}, \nQuery: {}", message, query),
|
||||||
|
@ -19,7 +19,7 @@ impl ReturnableErrorShape for Error {
|
|||||||
match self {
|
match self {
|
||||||
Error::Unspecified => TypedHttpResponse::return_standard_error(status_code, MessageResource::new_empty()),
|
Error::Unspecified => TypedHttpResponse::return_standard_error(status_code, MessageResource::new_empty()),
|
||||||
Error::NetworkError(message) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
Error::NetworkError(message) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
||||||
Error::UnexpectedStatusCode(_, actual, message) => TypedHttpResponse::return_standard_error(*actual, message.clone()),
|
Error::UnexpectedStatusCode(_, actual, messages) => TypedHttpResponse::return_standard_error_list(*actual, messages.clone()),
|
||||||
Error::ClientError(message) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
Error::ClientError(message) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
||||||
Error::SerdeError(message, _) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
Error::SerdeError(message, _) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
||||||
Error::DatabaseError(message, _) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
Error::DatabaseError(message, _) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
|
||||||
|
Loading…
Reference in New Issue
Block a user