diff --git a/bin/cli.js b/bin/cli.js index f6655163d..49d7baf2c 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -43,6 +43,7 @@ const timeStart = process.hrtime(); spec = await loadSpec(pathToSpec); } catch (e) { console.error(chalk.red(`❌ "${e}"`)); + return; } const result = swaggerToTS(spec, { diff --git a/bin/loaders/index.js b/bin/loaders/index.js index 750b91939..51b0f6403 100644 --- a/bin/loaders/index.js +++ b/bin/loaders/index.js @@ -26,10 +26,14 @@ module.exports.loadSpec = async (pathToSpec) => { if (isYamlSpec(rawSpec, pathToSpec)) { return yaml.safeLoad(rawSpec); } - } catch { - throw new Error( - `The spec under ${pathToSpec} seems to be YAML, but it couldn’t be parsed.` - ); + } catch (err) { + let message = `The spec under ${pathToSpec} seems to be YAML, but it couldn’t be parsed.`; + + if (err.message) { + message += `\n${err.message}`; + } + + throw new Error(message); } try {