Replies: 1 comment
-
What you want to do is interesting.
Currently, it does not support |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using custom errors to simplify and standardize formatting of responses returned to the client. An example is the validation error below.
I can then throw a validation error and not worry about specific status codes, and later also add specific validation messages that specify which fields were invalid in a POST request for example, and display those at appropriate places in a client side form.
This is used with a custom
onError
handler:When used with hono/client, the response I receive is typed as successful response and does not allow for a
body
type adjusted to the error version.Typescript will show an error for the code above, saying
Object literal may only specify known properties, and 'message' does not exist in type ...
.Is there a way I could customize the
ClientResponse
type based on the status code, so that it understands there is a successful and a failed response? It's really ugly having to writebody as xy
all over the code.Thank you
Beta Was this translation helpful? Give feedback.
All reactions