Skip to content

Commit 7f86900

Browse files
committed
fix: do not required data property
Release-As: v2.4.0
1 parent eced086 commit 7f86900

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

packages/ebec/src/check.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,5 @@ export function isBaseError(
2323
return false;
2424
}
2525

26-
if (!isObject(input.data)) {
27-
return false;
28-
}
29-
3026
return typeof input.message === 'string';
3127
}

packages/ebec/src/module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class BaseError extends Error {
2222
* unstructured information or supplementary details that provide context
2323
* to the error.
2424
*/
25-
readonly data: ObjectLiteral;
25+
readonly data?: ObjectLiteral;
2626

2727
/**
2828
* Determines whether the error message can be safely exposed externally.
@@ -73,6 +73,6 @@ export class BaseError extends Error {
7373
this.expose = options.expose;
7474
this.logMessage = options.logMessage;
7575
this.logLevel = options.logLevel;
76-
this.data = options.data || {};
76+
this.data = options.data;
7777
}
7878
}

packages/ebec/test/unit/module.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('src/module.ts', () => {
2323
foo: 'bar',
2424
},
2525
});
26-
expect(error.code).toEqual('bar');
26+
expect(error.data).toEqual({ foo: 'bar' });
2727
});
2828

2929
it('should recognize error', () => {

0 commit comments

Comments
 (0)