refactor(core): Extend error hierarchy (#12267)

This commit is contained in:
Tomi Turtiainen
2025-02-18 17:47:11 +02:00
committed by GitHub
parent 1e1f528466
commit 2ab59d775b
15 changed files with 293 additions and 28 deletions

View File

@@ -0,0 +1,26 @@
import { BaseError } from '@/errors/base/base.error';
import { UnexpectedError } from '@/errors/base/unexpected.error';
describe('UnexpectedError', () => {
it('should be an instance of UnexpectedError', () => {
const error = new UnexpectedError('test');
expect(error).toBeInstanceOf(UnexpectedError);
});
it('should be an instance of BaseError', () => {
const error = new UnexpectedError('test');
expect(error).toBeInstanceOf(BaseError);
});
it('should have correct defaults', () => {
const error = new UnexpectedError('test');
expect(error.level).toBe('error');
expect(error.shouldReport).toBe(true);
});
it('should allow overriding the default level and shouldReport', () => {
const error = new UnexpectedError('test', { level: 'fatal', shouldReport: false });
expect(error.level).toBe('fatal');
expect(error.shouldReport).toBe(false);
});
});