Skip to content

Commit 8578d50

Browse files
committed
ref: Move ExtendedError to a types package
1 parent 04d1c80 commit 8578d50

File tree

10 files changed

+16
-56
lines changed

10 files changed

+16
-56
lines changed

packages/browser/src/integrations/linkederrors.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
2-
import { Event, EventHint, Exception, Integration } from '@sentry/types';
2+
import { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types';
33
import { exceptionFromStacktrace } from '../parsers';
44
import { computeStackTrace } from '../tracekit';
55

66
const DEFAULT_KEY = 'cause';
77
const DEFAULT_LIMIT = 5;
88

9-
/**
10-
* Just an Error object with arbitrary attributes attached to it.
11-
*/
12-
interface ExtendedError extends Error {
13-
[key: string]: any;
14-
}
15-
169
/** Adds SDK info to an event. */
1710
export class LinkedErrors implements Integration {
1811
/**

packages/browser/test/integrations/linkederrors.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import { expect } from 'chai';
22
import { stub } from 'sinon';
33
import { BrowserBackend } from '../../src/backend';
44
import { LinkedErrors } from '../../src/integrations/linkederrors';
5+
import { ExtendedError } from '@sentry/types';
56

67
let linkedErrors: LinkedErrors;
78

8-
interface ExtendedError extends Error {
9-
[key: string]: any;
10-
}
11-
129
describe('LinkedErrors', () => {
1310
beforeEach(() => {
1411
linkedErrors = new LinkedErrors();

packages/core/src/integrations/extraerrordata.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/hub';
2-
import { Event, EventHint, Integration } from '@sentry/types';
3-
import { isError, isString } from '@sentry/utils/is';
2+
import { Event, EventHint, ExtendedError, Integration } from '@sentry/types';
3+
import { isError, isPlainObject } from '@sentry/utils/is';
44
import { logger } from '@sentry/utils/logger';
55
import { safeNormalize } from '@sentry/utils/object';
66

7-
/**
8-
* Just an Error object with arbitrary attributes attached to it.
9-
*/
10-
interface ExtendedError extends Error {
11-
[key: string]: unknown;
12-
}
137

148
/** Patch toString calls to return proper name for wrapped functions */
159
export class ExtraErrorData implements Integration {

packages/core/test/lib/integrations/extraerrordata.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import { SentryEvent } from '@sentry/types';
1+
import { ExtendedError, SentryEvent } from '@sentry/types';
22
import { ExtraErrorData } from '../../../src/integrations/extraerrordata';
33

4-
/**
5-
* Just an Error object with arbitrary attributes attached to it.
6-
*/
7-
interface ExtendedError extends Error {
8-
[key: string]: any;
9-
}
10-
114
const extraErrorData = new ExtraErrorData();
125
let event: SentryEvent;
136

packages/node/src/integrations/linkederrors.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
2-
import { Event, EventHint, Exception, Integration } from '@sentry/types';
2+
import { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types';
33
import { SyncPromise } from '@sentry/utils/syncpromise';
44
import { getExceptionFromError } from '../parsers';
55

66
const DEFAULT_KEY = 'cause';
77
const DEFAULT_LIMIT = 5;
88

9-
/**
10-
* Just an Error object with arbitrary attributes attached to it.
11-
*/
12-
interface ExtendedError extends Error {
13-
[key: string]: any;
14-
}
15-
169
/** Adds SDK info to an event. */
1710
export class LinkedErrors implements Integration {
1811
/**

packages/node/src/parsers.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Event, Exception, StackFrame } from '@sentry/types';
1+
import { Event, Exception, ExtendedError, StackFrame } from '@sentry/types';
22
import { basename, dirname } from '@sentry/utils/path';
33
import { snipLine } from '@sentry/utils/string';
44
import { SyncPromise } from '@sentry/utils/syncpromise';
@@ -19,13 +19,6 @@ export function resetFileContentCache(): void {
1919
FILE_CONTENT_CACHE.clear();
2020
}
2121

22-
/**
23-
* Just an Error object with arbitrary attributes attached to it.
24-
*/
25-
interface ExtendedError extends Error {
26-
[key: string]: any;
27-
}
28-
2922
/** JSDoc */
3023
function getFunction(frame: stacktrace.StackFrame): string {
3124
try {

packages/node/test/integrations/linkederrors.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1+
import { ExtendedError } from '@sentry/types';
12
import { Event } from '../../src';
23
import { NodeBackend } from '../../src/backend';
34
import { LinkedErrors } from '../../src/integrations/linkederrors';
45

56
let linkedErrors: LinkedErrors;
67

7-
interface ExtendedError extends Error {
8-
[key: string]: any;
9-
}
10-
118
describe('LinkedErrors', () => {
129
beforeEach(() => {
1310
linkedErrors = new LinkedErrors();

packages/types/src/error.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Just an Error object with arbitrary attributes attached to it.
3+
*/
4+
export interface ExtendedError extends Error {
5+
[key: string]: any;
6+
}

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export { Breadcrumb, BreadcrumbHint } from './breadcrumb';
22
export { Client } from './client';
33
export { Dsn, DsnComponents, DsnLike, DsnProtocol } from './dsn';
4+
export { ExtendedError } from './error';
45
export { Event, EventHint } from './event';
56
export { EventProcessor } from './eventprocessor';
67
export { Exception } from './exception';

packages/utils/src/object.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import { WrappedFunction } from '@sentry/types';
1+
import { WrappedFunction, ExtendedError } from '@sentry/types';
22
import { isArray, isNaN, isPlainObject, isPrimitive, isUndefined } from './is';
33
import { Memo } from './memo';
44
import { truncate } from './string';
55

6-
/**
7-
* Just an Error object with arbitrary attributes attached to it.
8-
*/
9-
interface ExtendedError extends Error {
10-
[key: string]: any;
11-
}
12-
136
/**
147
* Serializes the given object into a string.
158
* Like JSON.stringify, but doesn't throw on circular references.

0 commit comments

Comments
 (0)