Open wyrd-code opened 9 months ago
I am trying to return a structured error response from the server, so I can return several validation messages at once for for example.
ie with an onError server handler like this
.onError((context) => { const { code, error, set } = context switch (code) { case 'VALIDATION_ERROR': set.status = 422 return { message: error.toString().replace('Error: ', '') fields: [] } } })
But when a request fails, the eden fetch error.value type is a string:
error.value
const { data, error} = await fetch('/endpoint')
It would be nice to be able to customize the returned error type, so I could access error.value.message and have it properly typed too.
error.value.message
I am trying to return a structured error response from the server, so I can return several validation messages at once for for example.
ie with an onError server handler like this
But when a request fails, the eden fetch
error.value
type is a string:It would be nice to be able to customize the returned error type, so I could access
error.value.message
and have it properly typed too.