Skip to content

Commit 9c21482

Browse files
committed
Revert "fix: throwThroughErrorTypes skips Sentry capture (HI-02)"
This reverts commit 0273820.
1 parent 0273820 commit 9c21482

3 files changed

Lines changed: 16 additions & 23 deletions

File tree

.changeset/throw-through-skips-sentry.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/__tests__/Try.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ describe('Try', () => {
406406
.unwrap();
407407

408408
await expect(exec).rejects.toThrow('validation error');
409-
expect(Sentry.captureException).not.toHaveBeenCalled();
410409
});
411410

412411
it('should not give typescript error', async () => {
@@ -1243,7 +1242,6 @@ describe('Try', () => {
12431242
.report('failed')
12441243
.unwrap();
12451244
}).toThrow('validation error');
1246-
expect(Sentry.captureException).not.toHaveBeenCalled();
12471245
});
12481246

12491247
it('should not give typescript error', () => {

src/core/Try.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,20 @@ export class Try<
185185
}
186186

187187
/**
188-
* Configure error types that should be thrown through without being wrapped
189-
* AND without being reported to the configured Reporter (Sentry).
190-
* When using `.report()`, errors matching these types are re-thrown as-is
191-
* and `Reporter.report()` is NOT called for them. Breadcrumbs configured via
192-
* `.breadcrumbs()` are still recorded.
188+
* Configure error types that should be thrown through without being wrapped.
189+
* When using `.report()`, errors matching these types will be re-thrown as-is
190+
* instead of being wrapped with the custom message.
193191
*
194192
* @param ignoreErrorTypes Array of error type names (error.name) to throw through
195193
*
196194
* @example
197195
* ```typescript
198-
* // Configure to throw ValidationError and AuthError as-is (and skip Sentry)
196+
* // Configure to throw ValidationError and AuthError as-is
199197
* Try.throwThroughErrorTypes(['ValidationError', 'AuthError']);
200198
*
201-
* // Now these errors won't be wrapped or sent to Sentry:
199+
* // Now these errors won't be wrapped:
202200
* await new Try(validateUser, userData)
203-
* .report('User validation failed') // ValidationError throws as-is, no captureException
201+
* .report('User validation failed') // ValidationError will be thrown as-is
204202
* .unwrap();
205203
* ```
206204
*/
@@ -489,18 +487,18 @@ export class Try<
489487
if (isPromiseLike<TryResult<TReturn>>(result)) {
490488
return result.then((resolved) => {
491489
if (!resolved.success) {
492-
const isThrowThrough = Try.ignoreErrorTypes.includes(
493-
resolved.error.name,
494-
);
495-
const shouldCapture = this.config.message && !isThrowThrough;
490+
const shouldCapture = this.config.message;
496491

497492
if (shouldCapture) {
498493
this.reportError(resolved.error);
499494
} else if (this.config.breadcrumbConfig) {
500495
this.addBreadcrumbsIfConfigured();
501496
}
502497

503-
if (this.config.message && !isThrowThrough) {
498+
if (
499+
this.config.message &&
500+
!Try.ignoreErrorTypes.includes(resolved.error.name)
501+
) {
504502
const wrappedError = Try.defaultReporter.createWrappedError(
505503
resolved.error,
506504
this.config.message,
@@ -515,16 +513,18 @@ export class Try<
515513
}
516514

517515
if (!result.success) {
518-
const isThrowThrough = Try.ignoreErrorTypes.includes(result.error.name);
519-
const shouldCapture = this.config.message && !isThrowThrough;
516+
const shouldCapture = this.config.message;
520517

521518
if (shouldCapture) {
522519
this.reportError(result.error);
523520
} else if (this.config.breadcrumbConfig) {
524521
this.addBreadcrumbsIfConfigured();
525522
}
526523

527-
if (this.config.message && !isThrowThrough) {
524+
if (
525+
this.config.message &&
526+
!Try.ignoreErrorTypes.includes(result.error.name)
527+
) {
528528
const wrappedError = Try.defaultReporter.createWrappedError(
529529
result.error,
530530
this.config.message,

0 commit comments

Comments
 (0)