From c6dd283d04ad4ff4a704f557ede4c08280e067c1 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Tue, 9 Jan 2024 14:53:11 -0600 Subject: [PATCH] fix: add spinner catch statement --- src/lib/prepareOas.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/lib/prepareOas.ts b/src/lib/prepareOas.ts index ace10b551..d33ede641 100644 --- a/src/lib/prepareOas.ts +++ b/src/lib/prepareOas.ts @@ -174,13 +174,20 @@ export default async function prepareOas( // And though `.validate()` will run `.load()` itself running `.load()` here will not have any // performance implications as `oas-normalizes` caches the result of `.load()` the first time you // run it. - const { specType, definitionVersion } = await oas.load().then(async schema => { - const type = getAPIDefinitionType(schema); - return { - specType: capitalizeSpecType(type), - definitionVersion: await oas.version(), - }; - }); + const { specType, definitionVersion } = await oas + .load() + .then(async schema => { + const type = getAPIDefinitionType(schema); + return { + specType: capitalizeSpecType(type), + definitionVersion: await oas.version(), + }; + }) + .catch((err: Error) => { + spinner.fail(); + debug(`raw oas load error object: ${JSON.stringify(err)}`); + throw err; + }); // If we were supplied a Postman collection this will **always** convert it to OpenAPI 3.0. let api: OpenAPI.Document = await oas.validate({ convertToLatest: opts.convertToLatest }).catch((err: Error) => {