Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable exceptions #325

Open
ecyrbe opened this issue Feb 7, 2023 · 5 comments
Open

Add an option to disable exceptions #325

ecyrbe opened this issue Feb 7, 2023 · 5 comments
Labels
enhancement New feature or request pinned issues that should not be closed by bot v11 target

Comments

@ecyrbe
Copy link
Owner

ecyrbe commented Feb 7, 2023

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
}
@ecyrbe ecyrbe added enhancement New feature or request v11 target labels Feb 7, 2023
@tonyxiao
Copy link

tonyxiao commented Mar 3, 2023

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?

@ecyrbe
Copy link
Owner Author

ecyrbe commented Mar 3, 2023

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

@tonyxiao
Copy link

tonyxiao commented Mar 4, 2023

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)

@stale
Copy link

stale bot commented Apr 3, 2023

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.

@stale stale bot added the wontfix This will not be worked on label Apr 3, 2023
@ecyrbe ecyrbe added the pinned issues that should not be closed by bot label Apr 3, 2023
@stale stale bot removed the wontfix This will not be worked on label Apr 3, 2023
@michael-land
Copy link

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" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned issues that should not be closed by bot v11 target
Projects
None yet
Development

No branches or pull requests

3 participants