From 2302fbb026fbdc31fbaba83d68093e4b5610e1e8 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Wed, 29 Mar 2023 12:24:33 +0200 Subject: [PATCH] Add meaningful error when build expires (#92) --- tools-public/toolpad/bundleSizeQueries.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools-public/toolpad/bundleSizeQueries.ts b/tools-public/toolpad/bundleSizeQueries.ts index 46cb82c..9591052 100644 --- a/tools-public/toolpad/bundleSizeQueries.ts +++ b/tools-public/toolpad/bundleSizeQueries.ts @@ -48,14 +48,18 @@ async function getBaseSnapshot(baseRef: string, baseCommit: string) { } async function getTargetSnapshot(circleCIBuildNumber: string) { - const { data: artifacts } = await axios.get( - `https://circleci.com/api/v2/project/gh/mui/material-ui/${encodeURIComponent( - circleCIBuildNumber - )}/artifacts` - ); + const artifactsUrl = `https://circleci.com/api/v2/project/gh/mui/material-ui/${encodeURIComponent( + circleCIBuildNumber + )}/artifacts`; + const { data: artifacts } = await axios.get(artifactsUrl); const entry = artifacts.items.find( (entry) => entry.path === "size-snapshot.json" ); + if (!entry) { + throw new Error( + `No artifacts found for build ${circleCIBuildNumber} (${artifactsUrl})` + ); + } const { data } = await axios.get(entry.url); return data; }