From 39527cf8153db6cda0492041d510c83411f10aee Mon Sep 17 00:00:00 2001 From: markzegarelli Date: Tue, 13 Dec 2022 12:05:06 -0800 Subject: [PATCH] Don't nuke the whole file if 404 --- scripts/private-destination.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/private-destination.js b/scripts/private-destination.js index 2ec0efda6c..d0bda0305e 100644 --- a/scripts/private-destination.js +++ b/scripts/private-destination.js @@ -20,8 +20,9 @@ const PRIVATE_DESTINATIONS = yaml.load(fs.readFileSync(path.resolve(__dirname, ` const privateDests = PRIVATE_DESTINATIONS.items let private = [] const getCatalog = async (url, page_token = "MA==") => { + let res = null try { - const res = await axios.get(url, { + res = await axios.get(url, { headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.PAPI_TOKEN}` @@ -33,10 +34,14 @@ const getCatalog = async (url, page_token = "MA==") => { } } }); - return res.data - } catch (error) { - console.log(error) + } catch (err) { + console.error("Error response:"); + console.error(err.response.data); // *** + console.error(err.response.status); // *** + console.error(err.response.headers); // *** + } finally { + } } @@ -48,6 +53,9 @@ const checkDestinationStatus = async (id) => { } const getDestinationData = async (id) => { const res = await getCatalog(`${PAPI_URL}/catalog/destinations/${id}`) + if (res == null) { + return + } let destination = res.data.destinationMetadata let settings = destination.options settings.sort((a, b) => {