Skip to content

Commit

Permalink
fix: add hint to simple parser error message (#3399)
Browse files Browse the repository at this point in the history
Closing #3394
  • Loading branch information
stepan662 authored Nov 6, 2024
1 parent 69a36c2 commit 3587074
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/FormatSimple/FormatError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ export class FormatError extends Error {
public readonly index: number;
constructor(code: ErrorCode, index: number, text: string) {
let error: string;
let hint = '';
if (code === ERROR_PARAM_EMPTY) {
error = 'Empty parameter';
} else if (code === ERROR_UNEXPECTED_CHAR) {
error = 'Unexpected character';
hint = 'Did you forget to use FormatIcu to render ICU message syntax?';
} else {
error = 'Unexpected end';
}
super(`Tolgee parser: ${error} at ${index} in "${text}"`);
super(
`Tolgee parser: ${error} at ${index} in "${text}"` +
(hint ? '\n' + hint : '')
);
this.code = code;
this.index = index;
}
Expand Down

0 comments on commit 3587074

Please sign in to comment.