Skip to content

Commit

Permalink
Update error.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Feb 5, 2025
1 parent 125012c commit dc0199f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rust/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ impl Error {
}
}

/// Returns the OpenAPI error code
pub fn openapi_error_code(&self) -> Option<i64> {
match self {
Error::HttpClient(HttpClientError::OpenApi { code, .. }) => Some(*code as i64),
Error::WsClient(WsClientError::ResponseError { detail, .. }) => {
detail.as_ref().map(|detail| detail.code as i64)
}
_ => None,
}
}

/// Consumes this error and returns a simple error
pub fn into_simple_error(self) -> SimpleError {
match self {
Expand Down

0 comments on commit dc0199f

Please sign in to comment.