Append original stack when WebClient#apiCall throws
Summary
When an API call within @slack/web-api fails, the resulting error's stack loses the call context:
Error: An API error occurred: account_inactive
at Object.platformErrorFromResult (/project/node_modules/@slack/web-api/src/errors.ts:94:5)
at WebClient.apiCall (/project/node_modules/@slack/web-api/src/WebClient.ts:188:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
This PR appends the original stack leading up to the call so that developers can more easily trace failing calls.
For more details, see https://github.com/slackapi/node-slack-sdk/issues/561#issuecomment-679265974
Requirements (place an x in each [ ])
- [x] I've read and understood the Contributing Guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
Codecov Report
Merging #1086 into main will increase coverage by
0.02%. The diff coverage isn/a.
@@ Coverage Diff @@
## main #1086 +/- ##
==========================================
+ Coverage 94.34% 94.37% +0.02%
==========================================
Files 12 12
Lines 796 800 +4
Branches 177 177
==========================================
+ Hits 751 755 +4
Misses 15 15
Partials 30 30
| Flag | Coverage Δ | |
|---|---|---|
| #eventsapi | 90.74% <ø> (ø) |
|
| #interactivemessages | 94.83% <ø> (ø) |
|
| #webapi | 95.63% <ø> (+0.05%) |
:arrow_up: |
| #webhook | 87.50% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/WebClient.ts | 94.05% <0.00%> (+0.12%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update caa1fd0...c272377. Read the comment docs.
Hey @vaskevich!
Thanks for sending this in.
Ended up commenting on the issue to continue discussion
This would really improve the developer experience. Currently, errors thrown by the web client are only referencing the stack as they know it when the promise is being resolved. This means we often cannot determine the source of the error without painstaking debugging and isolation steps.