Improve context for errors thrown by compiler
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.
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import type { NodeData } from '@/application/Parser/NodeValidation/NodeData';
|
||||
import type { INodeDataErrorContext } from '@/application/Parser/NodeValidation/NodeDataError';
|
||||
import { NodeType } from '@/application/Parser/NodeValidation/NodeType';
|
||||
import type { NodeDataErrorContext } from '@/application/Parser/NodeValidation/NodeDataErrorContext';
|
||||
import { NodeDataType } from '@/application/Parser/NodeValidation/NodeDataType';
|
||||
import { CategoryDataStub } from './CategoryDataStub';
|
||||
|
||||
export class NodeDataErrorContextStub implements INodeDataErrorContext {
|
||||
public readonly type: NodeType = NodeType.Script;
|
||||
|
||||
public readonly selfNode: NodeData = new CategoryDataStub();
|
||||
|
||||
public readonly parentNode?: NodeData;
|
||||
export function createNodeDataErrorContextStub(): NodeDataErrorContext {
|
||||
return {
|
||||
type: NodeDataType.Category,
|
||||
selfNode: new CategoryDataStub(),
|
||||
parentNode: new CategoryDataStub(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user