Skip to content

Commit e8aaa39

Browse files
Unwrap SDW errors before sending to Sentry (#7735)
* Unwrap SDW errors before sending to Sentry * Create honest-spies-prove.md * Update .changeset/honest-spies-prove.md Co-authored-by: Pete Bacon Darwin <[email protected]> * Less assigning * Fix typing issues --------- Co-authored-by: Pete Bacon Darwin <[email protected]>
1 parent 713f4e8 commit e8aaa39

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.changeset/honest-spies-prove.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Unwrap the error cause when available to send to Sentry

packages/wrangler/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,7 @@ export async function main(argv: string[]): Promise<void> {
10061006
cliHandlerThrew = true;
10071007
let mayReport = true;
10081008
let errorType: string | undefined;
1009+
let loggableException = e;
10091010

10101011
logger.log(""); // Just adds a bit of space
10111012
if (e instanceof CommandLineArgsError) {
@@ -1071,7 +1072,6 @@ export async function main(argv: string[]): Promise<void> {
10711072
errorType = "BuildFailure";
10721073
logBuildFailure(e.cause.errors, e.cause.warnings);
10731074
} else {
1074-
let loggableException = e;
10751075
if (
10761076
// Is this a StartDevEnv error event? If so, unwrap the cause, which is usually the user-recognisable error
10771077
e &&
@@ -1102,13 +1102,12 @@ export async function main(argv: string[]): Promise<void> {
11021102
// Only report the error if we didn't just handle it
11031103
mayReport &&
11041104
// ...and it's not a user error
1105-
!(e instanceof UserError) &&
1105+
!(loggableException instanceof UserError) &&
11061106
// ...and it's not an un-reportable API error
1107-
!(e instanceof APIError && !e.reportable)
1107+
!(loggableException instanceof APIError && !loggableException.reportable)
11081108
) {
1109-
await captureGlobalException(e);
1109+
await captureGlobalException(loggableException);
11101110
}
1111-
11121111
const durationMs = Date.now() - startTime;
11131112

11141113
dispatcher?.sendCommandEvent(

0 commit comments

Comments
 (0)