mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-12 03:45:34 +00:00
fix(developer): remove extra fatal exception
- remove the fatal exception about a failed section compiler, as it will always otherwise be propagated to the user Fixes: #10894
This commit is contained in:
parent
de503729e7
commit
e77a495477
5 changed files with 23 additions and 9 deletions
|
|
@ -343,11 +343,7 @@ export class LdmlKeyboardCompiler implements KeymanCompiler {
|
||||||
}
|
}
|
||||||
const sect = section.compile(globalSections);
|
const sect = section.compile(globalSections);
|
||||||
|
|
||||||
/* c8 ignore next 7 */
|
|
||||||
if(!sect) {
|
if(!sect) {
|
||||||
// This should not happen -- validate() should have told us
|
|
||||||
// if something is going to fail to compile
|
|
||||||
this.callbacks.reportMessage(CompilerMessages.Fatal_SectionCompilerFailed({sect:section.id}));
|
|
||||||
passed = false;
|
passed = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { util, CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m, CompilerMessageDef as def, CompilerMessageSpecWithException } from "@keymanapp/common-types";
|
import { util, CompilerErrorNamespace, CompilerErrorSeverity, CompilerMessageSpec as m, CompilerMessageDef as def } from "@keymanapp/common-types";
|
||||||
// const SevInfo = CompilerErrorSeverity.Info | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
// const SevInfo = CompilerErrorSeverity.Info | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
||||||
const SevHint = CompilerErrorSeverity.Hint | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
const SevHint = CompilerErrorSeverity.Hint | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
||||||
const SevWarn = CompilerErrorSeverity.Warn | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
const SevWarn = CompilerErrorSeverity.Warn | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
||||||
const SevError = CompilerErrorSeverity.Error | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
const SevError = CompilerErrorSeverity.Error | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
||||||
const SevFatal = CompilerErrorSeverity.Fatal | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
// const SevFatal = CompilerErrorSeverity.Fatal | CompilerErrorNamespace.LdmlKeyboardCompiler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
|
@ -59,9 +59,7 @@ export class CompilerMessages {
|
||||||
static Error_MustBeAtLeastOneLayerElement = () =>
|
static Error_MustBeAtLeastOneLayerElement = () =>
|
||||||
m(this.ERROR_MustBeAtLeastOneLayerElement, `The source file must contain at least one layer element.`);
|
m(this.ERROR_MustBeAtLeastOneLayerElement, `The source file must contain at least one layer element.`);
|
||||||
|
|
||||||
static FATAL_SectionCompilerFailed = SevFatal | 0x000F;
|
// 0x000F - available
|
||||||
static Fatal_SectionCompilerFailed = (o:{sect: string}) =>
|
|
||||||
CompilerMessageSpecWithException(this.FATAL_SectionCompilerFailed, null, `The compiler for '${def(o.sect)}' failed unexpectedly.`);
|
|
||||||
|
|
||||||
/** annotate the to= or id= entry */
|
/** annotate the to= or id= entry */
|
||||||
private static outputOrKeyId(o:{output?: string, keyId?: string}) {
|
private static outputOrKeyId(o:{output?: string, keyId?: string}) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,13 @@
|
||||||
|
|
||||||
<keys />
|
<keys />
|
||||||
|
|
||||||
|
<!-- this is here because this test is used by test-compiler-e2e -->
|
||||||
|
<layers formId="us">
|
||||||
|
<layer id="base">
|
||||||
|
<row keys="a b c" />
|
||||||
|
</layer>
|
||||||
|
</layers>
|
||||||
|
|
||||||
<transforms type="simple">
|
<transforms type="simple">
|
||||||
<transformGroup>
|
<transformGroup>
|
||||||
<transform from="\u0127" to="x"/> <!-- fail: use \u{1234} instead -->
|
<transform from="\u0127" to="x"/> <!-- fail: use \u{1234} instead -->
|
||||||
|
|
|
||||||
|
|
@ -117,4 +117,16 @@ describe('compiler-tests', function() {
|
||||||
]);
|
]);
|
||||||
assert.isNotNull(kmx);
|
assert.isNotNull(kmx);
|
||||||
});
|
});
|
||||||
|
it('should fail on extra escapes - sections/tran/fail-bad-tran-2.xml', async function() {
|
||||||
|
const inputFilename = makePathToFixture('sections/tran/fail-bad-tran-2.xml');
|
||||||
|
const kmx = await compileKeyboard(inputFilename, { ...compilerTestOptions, saveDebug: true, shouldAddCompilerVersion: false },
|
||||||
|
[
|
||||||
|
CompilerMessages.Error_InvalidQuadEscape({ cp: 295 }),
|
||||||
|
],
|
||||||
|
true, // validation should fail
|
||||||
|
[
|
||||||
|
// compiler messages (not reached, we've already failed)
|
||||||
|
]);
|
||||||
|
assert.isNull(kmx); // should fail post-validate
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,7 @@ describe('tran', function () {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// also used in test-compiler-e2e.ts
|
||||||
subpath: `sections/tran/fail-bad-tran-2.xml`,
|
subpath: `sections/tran/fail-bad-tran-2.xml`,
|
||||||
errors: [
|
errors: [
|
||||||
CompilerMessages.Error_InvalidQuadEscape({ cp: 295 }),
|
CompilerMessages.Error_InvalidQuadEscape({ cp: 295 }),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue