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
730 B
TypeScript
20 lines
730 B
TypeScript
import type { ScriptFactory } from '@/application/Parser/Script/ScriptParser';
|
|
import type { IScript } from '@/domain/IScript';
|
|
import type { ScriptInitParameters } from '@/domain/Script';
|
|
import { ScriptStub } from './ScriptStub';
|
|
|
|
export function createScriptFactorySpy(): {
|
|
readonly scriptFactorySpy: ScriptFactory;
|
|
getInitParameters: (category: IScript) => ScriptInitParameters | undefined;
|
|
} {
|
|
const createdScripts = new Map<IScript, ScriptInitParameters>();
|
|
return {
|
|
scriptFactorySpy: (parameters) => {
|
|
const script = new ScriptStub('script from factory stub');
|
|
createdScripts.set(script, parameters);
|
|
return script;
|
|
},
|
|
getInitParameters: (script) => createdScripts.get(script),
|
|
};
|
|
}
|