try to work better with minified code
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -22,8 +22,11 @@ import { isError } from './assertion';
|
||||
*
|
||||
* @public
|
||||
* @example
|
||||
*```ts
|
||||
* class MyCustomError extends CustomErrorBase {}
|
||||
*
|
||||
* ```ts
|
||||
* class MyCustomError extends CustomErrorBase {
|
||||
* name = 'MyCustomError' as const;
|
||||
* }
|
||||
*
|
||||
* const e = new MyCustomError('Some message', cause);
|
||||
* // e.name === 'MyCustomError'
|
||||
@@ -53,8 +56,11 @@ export class CustomErrorBase extends Error {
|
||||
|
||||
Error.captureStackTrace?.(this, this.constructor);
|
||||
|
||||
if (!this.name) {
|
||||
this.name = this.constructor.name;
|
||||
if (!this.name || this.name === 'Error') {
|
||||
const baseName = this.constructor.name;
|
||||
if (baseName !== 'Error') {
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
||||
this.cause = isError(cause) ? cause : undefined;
|
||||
|
||||
Reference in New Issue
Block a user