Skip to content

Commit 4d5e9a8

Browse files
committed
set error type undefined
1 parent 21db6f9 commit 4d5e9a8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/modules/exceptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ export function captureException(
3131
if (!(error instanceof Error)) {
3232
return {
3333
message: stringifyNonError(error),
34-
type: "UnknownErrorType",
34+
type: undefined,
3535
platform: "javascript",
3636
};
3737
}
3838

3939
const errorData: ErrorData = {
4040
message: error.message || "",
41-
type: error.name || error.constructor?.name || "Error",
41+
type: error.name || error.constructor?.name || undefined,
4242
platform: "javascript",
4343
};
4444

src/tests/exceptions.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ describe("captureException", () => {
306306
const result = captureException("string error");
307307

308308
expect(result.message).toBe("string error");
309-
expect(result.type).toBe("UnknownErrorType");
309+
expect(result.type).toBeUndefined();
310310
expect(result.stack).toBeUndefined();
311311
expect(result.frames).toBeUndefined();
312312
});
@@ -315,35 +315,35 @@ describe("captureException", () => {
315315
const result = captureException(42);
316316

317317
expect(result.message).toBe("42");
318-
expect(result.type).toBe("UnknownErrorType");
318+
expect(result.type).toBeUndefined();
319319
});
320320

321321
it("should handle boolean errors", () => {
322322
const result = captureException(false);
323323

324324
expect(result.message).toBe("false");
325-
expect(result.type).toBe("UnknownErrorType");
325+
expect(result.type).toBeUndefined();
326326
});
327327

328328
it("should handle null", () => {
329329
const result = captureException(null);
330330

331331
expect(result.message).toBe("null");
332-
expect(result.type).toBe("UnknownErrorType");
332+
expect(result.type).toBeUndefined();
333333
});
334334

335335
it("should handle undefined", () => {
336336
const result = captureException(undefined);
337337

338338
expect(result.message).toBe("undefined");
339-
expect(result.type).toBe("UnknownErrorType");
339+
expect(result.type).toBeUndefined();
340340
});
341341

342342
it("should handle object errors", () => {
343343
const result = captureException({ code: 404, message: "Not found" });
344344

345345
expect(result.message).toBe('{"code":404,"message":"Not found"}');
346-
expect(result.type).toBe("UnknownErrorType");
346+
expect(result.type).toBeUndefined();
347347
});
348348

349349
it("should handle objects with circular references", () => {
@@ -352,7 +352,7 @@ describe("captureException", () => {
352352

353353
const result = captureException(obj);
354354

355-
expect(result.type).toBe("UnknownErrorType");
355+
expect(result.type).toBeUndefined();
356356
// Should not throw, should return some string representation
357357
expect(typeof result.message).toBe("string");
358358
});

0 commit comments

Comments
 (0)