Skip to content

Commit f9c3667

Browse files
authored
bubble up the error message / improve error message when failing to parse the schema (#269)
1 parent fa07285 commit f9c3667

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

bin/cli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const timeStart = process.hrtime();
4343
spec = await loadSpec(pathToSpec);
4444
} catch (e) {
4545
console.error(chalk.red(`❌ "${e}"`));
46+
return;
4647
}
4748

4849
const result = swaggerToTS(spec, {

bin/loaders/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ module.exports.loadSpec = async (pathToSpec) => {
2626
if (isYamlSpec(rawSpec, pathToSpec)) {
2727
return yaml.safeLoad(rawSpec);
2828
}
29-
} catch {
30-
throw new Error(
31-
`The spec under ${pathToSpec} seems to be YAML, but it couldn’t be parsed.`
32-
);
29+
} catch (err) {
30+
let message = `The spec under ${pathToSpec} seems to be YAML, but it couldn’t be parsed.`;
31+
32+
if (err.message) {
33+
message += `\n${err.message}`;
34+
}
35+
36+
throw new Error(message);
3337
}
3438

3539
try {

0 commit comments

Comments
 (0)