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

Move the error unwrapper into common #1558

Merged
merged 8 commits into from
Dec 10, 2024
Merged

Conversation

forgetso
Copy link
Member

@forgetso forgetso commented Dec 4, 2024

No description provided.

@@ -52,6 +53,7 @@ export default function () {
},
pool: "forks", // forks is slower than 'threads' but more compatible with low-level libs (e.g. bcrypt)
testTimeout: 10000,
//disableConsoleIntercept: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove new unused comment

return { code, statusMessage, jsonError };
};

export function isZodError(err: unknown): err is ZodError {
Copy link
Contributor

Choose a reason for hiding this comment

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

using consts or functions? different declaration in same file between line 184 and line 218

Copy link
Member Author

Choose a reason for hiding this comment

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

I've changed it to a const.

Don't understand the second comment. What do you mean about a different declaration?

Copy link
Contributor

Choose a reason for hiding this comment

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

was trying to communicate:

Don't mind function or const, both are fine. Just imo best to keep consistent within files, not use both

@@ -176,3 +181,42 @@ export class ProsopoApiError extends ProsopoBaseError<ApiContextParams> {
this.code = code;
}
}

export const unwrapError = (err: ProsopoApiError | SyntaxError | ZodError) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this typed as a ProsopoApiError? Aren't there other error types which we might want to unwrap?

Copy link
Member Author

Choose a reason for hiding this comment

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

At the moment its only being used for ProsopoApiError, but yes it should probably be ProsopoBaseError. Changed.

@HughParry HughParry merged commit 2fdbbf4 into staging Dec 10, 2024
6 checks passed
@HughParry HughParry deleted the common-error-handler branch December 10, 2024 15:02
@prosoponator prosoponator mentioned this pull request Dec 13, 2024
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