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

Feature/nextjs apierror class support #33

Merged
merged 2 commits into from
Feb 2, 2022
Merged

Feature/nextjs apierror class support #33

merged 2 commits into from
Feb 2, 2022

Conversation

LeonardoZivieri
Copy link
Contributor

This pull request is to share the default way of throw an error in NextJS API handlers, instead to use a exclusive error class of the lib.

I was changed the HttpError extended class from Error to a NextJS class named ApiError (
used to throw the error by default ), imported from next/dist/next-server/server/api-utils, and in the instanceof check, I used the NextJS ApiError class to get the status code and the message.

In this way, is more common to have compartibility with other libs.

You will not have the described http error if use directly the ApiError instead of HttpError, but is possible to add the description if it's important

Sorry about any mistakes in the text, i'm learning english yet

Copy link
Contributor

@foyarash foyarash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you review, can you just fix that point please ?

@foyarash foyarash merged commit 7862c1c into premieroctet:master Feb 2, 2022
@LeonardoZivieri LeonardoZivieri deleted the feature/nextjs-apierror-class-support branch February 3, 2022 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants