Add an option to disable exceptions
Today for error handling, since we use exceptions, we need to use error handling helpers (ie isErrorFromAlias and isErrorFromPath) to check errors safely.
To improve error handling, we could also have the hability to disable exceptions and then return an object encapsulating the result.
This way, we can directly return a typed error without requiring to use a helper.
const client = new Zodios(baseurl, myApi, { enableExceptions: false } );
const { data: users, error } = await client.getUsers();
if( error ) {
// typed error
}
For quick and dirty code, sometimes I just want the type hint without the full validation as a API is known to be wrong. I'd like a quick way to disable the run time validation while still having hints too. Would this solve for that?
Not exactly, your use case would require to also handle data extraction from zodiosError. This proposal does not handle this use case. But if it's easy to add, we could add it to the todo list
yea would love that. Right now if response does not pass validation then i'm completely stuck (other than manually modifying generated code, as wee use openapi-zod-client)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
For quick and dirty code, sometimes I just want the type hint without the full validation as a API is known to be wrong. I'd like a quick way to disable the run time validation while still having hints too. Would this solve for that?
I think you can get just type hint with { validate:"none" }