-
Notifications
You must be signed in to change notification settings - Fork 337
Clean up apierrors and only include messages #1329
Conversation
Addresses #1157 |
src/commands/kv/namespace/site.rs
Outdated
.iter() | ||
.map(|e| e.message.clone()) | ||
.collect(); | ||
failure::bail!("ApiError {:?}", error_messages); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh actually - it looks like we already have a convenience function for this that should make it easier + uniform with the way we display errors.
It is crate::http::format_error
, and it takes an ApiFailure
, and an optional function to handle individual error codes.
So you could write something real quick to include the suggestions for codes 10026
and 10014
and pass it to that function. You can see an example of this in crate::src::commands::route::delete
, at the end there is a match result
and it calls http::format_error
This should allow us to display the error without making it look like an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(if i had thought of this before i would have pointed you in that direction!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
added a |
Makes API errors a little cleaner. Looked like this before
Error: [ApiError { code: 10037, message: "user is missing required permission \"#worker:edit\"", other: {} }]
Now it looks like
Error: Code 10037: user is missing required permission "#worker:edit" Edit your API Token to have correct permissions, or use the 'Edit Cloudflare Workers' API Token template.