Skip to content

Commit

Permalink
Merge ade0081 into 9e96850
Browse files Browse the repository at this point in the history
  • Loading branch information
AVykhrystyuk committed May 11, 2021
2 parents 9e96850 + ade0081 commit 1f8a623
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -66,7 +66,7 @@ module.exports = {
// '@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],

// Allow properties in ctors, as it reduces code duplicates
'@typescript-eslint/no-parameter-properties': ['error', { allows: ['private readonly'] }],
'@typescript-eslint/no-parameter-properties': ['error', { allows: ['private readonly', 'protected readonly', 'public readonly'] }],

'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
},
Expand Down
10 changes: 2 additions & 8 deletions src/interfaces/di-error.spec.ts
Expand Up @@ -13,7 +13,7 @@ describe('DependencyInjectionError', () => {
it('`.toString()` displays name and the message for a direct call', () => {
const error = new DependencyInjectionError('Error reason message');

assert.equal(error.toString(), 'DependencyInjectionError: Error reason message');
assert.strictEqual(error.toString(), 'DependencyInjectionError: Error reason message');
});

// eslint-disable-next-line prefer-arrow-callback
Expand All @@ -24,12 +24,6 @@ describe('DependencyInjectionError', () => {
const stackTraceLines = stackTrace.split('\n');
assert.ok(stackTrace.startsWith('DependencyInjectionError: Error reason message'));
assert.ok(stackTraceLines.length > 5);
assert.equal(stackTraceLines[1].indexOf('stackTraceTestCase'), 15);
});

it('Does not have enumerable properties - otherwise they will be displayed in `console.log(err)`', () => {
const error = new DependencyInjectionError('Error reason message');

assert.equal(Object.keys(error).length, 0);
assert.strictEqual(stackTraceLines[1].indexOf('stackTraceTestCase'), 15);
});
});
11 changes: 1 addition & 10 deletions src/interfaces/di-error.ts
@@ -1,18 +1,9 @@
export class DependencyInjectionError extends Error {
public constructor(message: string, innerError?: Error) {
public constructor(message: string, public readonly innerError?: Error) {
super(message);

// to resist minification error name is hard coded
defineProperty(this, 'name', 'DependencyInjectionError'); // this.constructor.name);

defineProperty(this, 'innerError', innerError);

// Maintains proper stack trace for where our error was thrown (only available on V8)
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor);
} else {
defineProperty(this, 'stack', new Error(message).stack);
}
}
}

Expand Down

0 comments on commit 1f8a623

Please sign in to comment.