This commit introduces a custom error object to provide additional context for errors throwing during parsing and compiling operations, improving troubleshooting. By integrating error context handling, the error messages become more informative and user-friendly, providing sequence of trace with context to aid in troubleshooting. Changes include: - Introduce custom error object that extends errors with contextual information. This replaces previous usages of `AggregateError` which is not displayed well by browsers when logged. - Improve parsing functions to encapsulate error context with more details. - Increase unit test coverage and refactor the related code to be more testable.
20 lines
752 B
TypeScript
20 lines
752 B
TypeScript
import type { CategoryFactory } from '@/application/Parser/CategoryParser';
|
|
import type { CategoryInitParameters } from '@/domain/Category';
|
|
import type { ICategory } from '@/domain/ICategory';
|
|
import { CategoryStub } from './CategoryStub';
|
|
|
|
export function createCategoryFactorySpy(): {
|
|
readonly categoryFactorySpy: CategoryFactory;
|
|
getInitParameters: (category: ICategory) => CategoryInitParameters | undefined;
|
|
} {
|
|
const createdCategories = new Map<ICategory, CategoryInitParameters>();
|
|
return {
|
|
categoryFactorySpy: (parameters) => {
|
|
const category = new CategoryStub(55);
|
|
createdCategories.set(category, parameters);
|
|
return category;
|
|
},
|
|
getInitParameters: (category) => createdCategories.get(category),
|
|
};
|
|
}
|