You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One common use case for bs-decode is a webserver that decodes the payload of a request. In this case, it would be desirable to send back a 400 response with a response that includes structured errors that are related to the structure of the request.
Something like:
{
"first_name": {
"error": "MissingField",
"description": "Field \"first_name\" is required but was not present"
},
"order_ids": [
{
"position": 3,
"error": "InvalidValue",
"description": "Expected number but found \"3\""
}
]
}
Not sure what the exact structure should be, but it should be something predictable and easy to describe, so that your webserver can document the errors it will return and clients can theoretically do something useful with that data structure.
We already have examples of converting the structured ParseError type to a string in a way that preserves some of the nesting structure, so I think this should be pretty doable.
The text was updated successfully, but these errors were encountered:
In looking at that example, I think it's important that we use the "error" field consistently so that it can be a discriminator to reconstruct the original error data. Specifically, looking at "order_ids" in that example, there's not enough information to expect the value to be an array.
One common use case for
bs-decode
is a webserver that decodes the payload of a request. In this case, it would be desirable to send back a400
response with a response that includes structured errors that are related to the structure of the request.Something like:
Not sure what the exact structure should be, but it should be something predictable and easy to describe, so that your webserver can document the errors it will return and clients can theoretically do something useful with that data structure.
We already have examples of converting the structured
ParseError
type to a string in a way that preserves some of the nesting structure, so I think this should be pretty doable.The text was updated successfully, but these errors were encountered: