Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit e667741

Browse files
committed
fix: expose API Blueprint parse errors to user
Fixes #31
1 parent 7d90a17 commit e667741

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/APIBlueprintImporter.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,18 @@ export default class APIBlueprintImporter {
4646
for (const item of items) {
4747
console.log('Importing Item');
4848
const parseResult = await parse({ source: item.content, mediaType: 'text/vnd.apiblueprint' });
49-
const importer = new APIElementImporter(context, defaultHost);
50-
importer.importAPI(parseResult.api);
49+
50+
if (parseResult.api) {
51+
const importer = new APIElementImporter(context, defaultHost);
52+
importer.importAPI(parseResult.api);
53+
}
54+
55+
parseResult.errors.forEach((error) => {
56+
const start = error.attributes.get('sourceMap').get(0).get(0).get(0);
57+
const line = start.attributes.get('line');
58+
const column = start.attributes.get('column');
59+
throw new Error(`${error.toValue()} on line ${line}:${column}`)
60+
});
5161
}
5262

5363
return true;

0 commit comments

Comments
 (0)