Skip to content

Commit

Permalink
🐛 Fix message reporting breaking on empty string (#1155)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeunEinser committed May 20, 2024
1 parent 7ecab07 commit a1f81c3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions __snapshots__/packages/core/test-out/parser/long.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/core/src/service/ErrorReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export class ErrorReporter {
severity = ErrorSeverity.Error,
info?: LanguageErrorInfo,
): void {
if (message.trim() === '') {
throw new Error('Tried to report an error with no message')
}
this.errors.push(
LanguageError.create(message, Range.get(range), severity, info),
)
Expand Down
2 changes: 1 addition & 1 deletion packages/locales/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Parameter =
export function localize(key: string, ...params: Parameter[]): string {
const value: string | undefined = Locales[language][key] ?? Locales.en[key]

return _resolveLocalePlaceholders(value, params) ?? ''
return _resolveLocalePlaceholders(value, params) ?? key
}

export function localeQuote(content: string) {
Expand Down
2 changes: 2 additions & 0 deletions packages/locales/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"linter-config-validator.name-convention.type": "Expects a string that contains a regular expression describing the name",
"linter-config-validator.wrapper": "%0%. See [the documentation](%1) for more information",
"long": "a long",
"long.between": "a long between %0% and %1%",
"mcfunction.checker.command.data-modify-unapplicable-operation": "Operation %0% can only be used on %1%; the target path has type %2% instead",
"mcfunction.completer.block.states.default-value": "Default: %0%",
"mcfunction.parser.entity-selector.arguments.not-applicable": "%0% is not applicable here",
Expand Down Expand Up @@ -153,6 +154,7 @@
"parser.integer.illegal": "Illegal integer that doesn't follow %0%",
"parser.list.value": "a value",
"parser.list.trailing-sep": "Trailing separation",
"parser.long.illegal": "Illegal long numeral that doesn't follow %0%",
"parser.record.key": "a key",
"parser.record.trailing-end": "Trailing separation",
"parser.record.unexpected-char": "Unexpected character %0%",
Expand Down

0 comments on commit a1f81c3

Please sign in to comment.