-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove new unused comment
packages/common/src/error.ts
Outdated
return { code, statusMessage, jsonError }; | ||
}; | ||
|
||
export function isZodError(err: unknown): err is ZodError { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
packages/common/src/error.ts
Outdated
@@ -176,3 +181,42 @@ export class ProsopoApiError extends ProsopoBaseError<ApiContextParams> { | |||
this.code = code; | |||
} | |||
} | |||
|
|||
export const unwrapError = (err: ProsopoApiError | SyntaxError | ZodError) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
No description provided.