Skip to content

Commit 2940056

Browse files
authored
feat: surface invalid request error message in Display (#35)
add 400 error string to fmt::Display for Error
1 parent 9b7ea60 commit 2940056

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ impl From<crate::openapi::models::model_401_error::Model401Error> for Error {
127127
impl From<crate::openapi::models::model_400_error::Model400Error> for Error {
128128
fn from(e: crate::openapi::models::model_400_error::Model400Error) -> Self {
129129
match e.code {
130-
crate::openapi::models::model_400_error::Code::InvalidRequest => Error::InvalidRequest,
130+
crate::openapi::models::model_400_error::Code::InvalidRequest => {
131+
Error::InvalidRequest(e.error)
132+
}
131133
_ => Error::Other(e.error),
132134
}
133135
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub enum Error {
2222
Reqwest(reqwest::Error),
2323
Serde(serde_json::Error),
2424
Io(std::io::Error),
25-
InvalidRequest,
25+
InvalidRequest(String),
2626
InvalidAccessToken,
2727
InvalidNonce,
2828
OperationNotAllowed,
@@ -40,7 +40,7 @@ impl fmt::Display for Error {
4040
Error::Reqwest(e) => ("reqwest", e.to_string()),
4141
Error::Serde(e) => ("serde", e.to_string()),
4242
Error::Io(e) => ("IO", e.to_string()),
43-
Error::InvalidRequest => ("response", "invalid request".to_string()),
43+
Error::InvalidRequest(error) => ("response", format!("invalid request: {}", error)),
4444
Error::InvalidAccessToken => ("response", "invalid access token".to_string()),
4545
Error::InvalidNonce => ("response", "invalid nonce".to_string()),
4646
Error::OperationNotAllowed => ("response", "operation not allowed".to_string()),

0 commit comments

Comments
 (0)