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

fix(Webhook): unknown error in catch block #73

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@top-gg/sdk",
"version": "3.1.2",
"version": "3.1.3",
"description": "Official Top.gg Node SDK",
"main": "./dist/index.js",
"scripts": {
Expand Down Expand Up @@ -37,7 +37,7 @@
"lint-staged": "^11.0.0",
"prettier": "^2.3.0",
"typedoc": "^0.21.0",
"typescript": "^4.2.4"
"typescript": "^4.4.4"
},
"dependencies": {
"node-fetch": "^2.6.1",
Expand Down
2 changes: 1 addition & 1 deletion src/structs/Webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class Webhook {
res.sendStatus(204);
}
} catch (err) {
this.options.error?.(err);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, what exactly is getting thrown from functions that isn't an error? If we're handling all errors with a 500 response, shouldn't they also be treated as an error on the library side? Maybe the correct move here should be to change the type of the error callback from Error to unknown

Copy link
Member Author

Choose a reason for hiding this comment

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

Are we sure we want to do this? It would be a breaking change. I'm not opposed but a major bump seems unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, this is also a breaking change technically, just more subtle

if (err instanceof Error) this.options.error?.(err);

res.sendStatus(500);
}
Expand Down