What is the feature you are proposing?
Currently parseResponse throws an DetailedError when the fetch has a non-OK status code.
This error is completely untyped.
I propose the following:
- adding a new function like
parseResponseWithError which returns an object (similar to how openapi-ts does it):
const { result, error } = await parseResponse(client.hello.$get())
- adding a way to force infer a DetailedError (no additional runtime code):
const result = await parseResponse(client.hello.$get()).catch(
(err: any) => {
if(err instanceof DetailedError) {
const e: DetailedError<typeof client.hello.$get> = err;
}
}
)
Current workaround, check each possible status code explicitly and then cast the err.data to InferResponseType<typeof client.hello.$get, 4xx>
What is the feature you are proposing?
Currently
parseResponsethrows anDetailedErrorwhen the fetch has a non-OK status code.This error is completely untyped.
I propose the following:
parseResponseWithErrorwhich returns an object (similar to how openapi-ts does it):Current workaround, check each possible status code explicitly and then cast the err.data to
InferResponseType<typeof client.hello.$get, 4xx>