Skip to content

Commit f061e78

Browse files
authored
better error message for old-style biblios (#451)
1 parent d99f4a7 commit f061e78

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/Spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,13 @@ ${this.opts.multipage ? `<li><span>Navigate to/from multipage</span><code>m</cod
13311331
);
13321332
const biblios = biblioContents.flatMap(c => JSON.parse(c) as ExportedBiblio | ExportedBiblio[]);
13331333
for (const biblio of biblios.concat(this.opts.extraBiblios ?? [])) {
1334+
if (biblio?.entries == null) {
1335+
let message = Object.keys(biblio ?? {}).some(k => k.startsWith('http'))
1336+
? 'This is an old-style biblio.'
1337+
: 'Biblio does not appear to be in the correct format, are you using an old-style biblio?';
1338+
message += ' You will need to update it to work with versions of ecmarkup >= 12.0.0.';
1339+
throw new Error(message);
1340+
}
13341341
this.biblio.addExternalBiblio(biblio);
13351342
for (const entry of biblio.entries) {
13361343
if (entry.type === 'op' && entry.effects?.length > 0) {

test/errors.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ ${M} </pre>
464464
}
465465
};
466466
await emu.build('foo/index.html', fetch, {
467-
ecma262Biblio: false,
468467
copyright: false,
469468
warn: e =>
470469
warnings.push({
@@ -939,6 +938,16 @@ ${M} </pre>
939938
);
940939
});
941940

941+
it('old-style biblio', async () => {
942+
await assert.rejects(async () => {
943+
const fetch = () => '';
944+
await emu.build('index.html', fetch, {
945+
copyright: false,
946+
extraBiblios: [{ 'https://tc39.es/ecma262/': [] }],
947+
});
948+
}, /old-style biblio/);
949+
});
950+
942951
describe('SDO defined over unknown production', () => {
943952
it('unknown production', async () => {
944953
await assertError(

test/utils.js

-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ async function assertError(obj, { ruleId, nodeType, message }, opts) {
3434
let rootFile = 'test-example.emu';
3535
if (opts?.asImport !== 'only') {
3636
await emu.build(rootFile, async () => html, {
37-
ecma262Biblio: false,
3837
copyright: false,
3938
warn: e =>
4039
warnings.push({
@@ -72,7 +71,6 @@ async function assertError(obj, { ruleId, nodeType, message }, opts) {
7271
let importWrapper = `<emu-import href="./import.emu"></emu-import>`;
7372
let fetch = name => (name === rootFile ? importWrapper : html);
7473
await emu.build(rootFile, fetch, {
75-
ecma262Biblio: false,
7674
copyright: false,
7775
warn: e =>
7876
warnings.push({
@@ -113,7 +111,6 @@ async function assertErrorFree(html, opts) {
113111
let warnings = [];
114112

115113
await emu.build('test-example.emu', async () => html, {
116-
ecma262Biblio: false,
117114
copyright: false,
118115
warn: e => warnings.push(e),
119116
...opts,

0 commit comments

Comments
 (0)