Skip to content

Commit f6889f2

Browse files
msujewspoenemann
authored andcommitted
Correctly pass parser error message
1 parent ce57c0f commit f6889f2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/langium/src/serializer/hydrator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class DefaultHydrator implements Hydrator {
6363
return {
6464
// We need to create shallow copies of the errors
6565
// The original errors inherit from the `Error` class, which is not transferable across worker threads
66-
lexerErrors: result.lexerErrors.map(e => ({ ...e })),
67-
parserErrors: result.parserErrors.map(e => ({ ...e })),
66+
lexerErrors: result.lexerErrors.map(e => ({ ...e, message: e.message })),
67+
parserErrors: result.parserErrors.map(e => ({ ...e, message: e.message })),
6868
value: this.dehydrateAstNode(result.value, this.createDehyrationContext(result.value))
6969
};
7070
}

packages/langium/test/parser/worker-thread-async-parser.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ describe('WorkerThreadAsyncParser', () => {
108108
expect(result.parserErrors).toHaveLength(1);
109109
expect(result.parserErrors[0].name).toBe('MismatchedTokenException');
110110
expect(result.parserErrors[0]).toHaveProperty('previousToken');
111+
expect(result.parserErrors[0]).toHaveProperty('message', "Expecting token of type ';' but found ``.");
111112
});
112113

113114
function createLargeFile(size: number): string {

0 commit comments

Comments
 (0)