From 0d0f788718deecc29ceacdde9ed94060bd67f426 Mon Sep 17 00:00:00 2001 From: John Hobbs Date: Thu, 17 Oct 2024 10:18:06 -0500 Subject: [PATCH] Move sentinel error messaging to external file. --- node-src/tasks/upload.ts | 8 +++----- node-src/ui/messages/errors/sentinelFileErrors.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 node-src/ui/messages/errors/sentinelFileErrors.ts diff --git a/node-src/tasks/upload.ts b/node-src/tasks/upload.ts index 934aef52e..d1b4d7e36 100644 --- a/node-src/tasks/upload.ts +++ b/node-src/tasks/upload.ts @@ -14,6 +14,7 @@ import { rewriteErrorMessage, throttle } from '../lib/utils'; import { waitForSentinel } from '../lib/waitForSentinel'; import { Context, FileDesc, Task } from '../types'; import missingStatsFile from '../ui/messages/errors/missingStatsFile'; +import sentinelFileErrors from '../ui/messages/errors/sentinelFileErrors'; import bailFile from '../ui/messages/warnings/bailFile'; import deviatingOutputDirectory from '../ui/messages/warnings/deviatingOutputDirectory'; import { @@ -277,11 +278,8 @@ export const waitForSentinels = async (ctx: Context, task: Task) => { try { await Promise.all(Object.values(sentinels).map((sentinel) => waitForSentinel(ctx, sentinel))); } catch (err) { - throw new Error( - `Failed to finalize upload. Please check https://status.chromatic.com/ or contact support. - -${err.message}` - ); + ctx.log.error(sentinelFileErrors()); + throw err; } }; diff --git a/node-src/ui/messages/errors/sentinelFileErrors.ts b/node-src/ui/messages/errors/sentinelFileErrors.ts new file mode 100644 index 000000000..64d745e0c --- /dev/null +++ b/node-src/ui/messages/errors/sentinelFileErrors.ts @@ -0,0 +1,9 @@ +import chalk from 'chalk'; +import { dedent } from 'ts-dedent'; + +import { error } from '../../components/icons'; + +export default () => + dedent(chalk` + ${error} Failed to finalize upload. Please check https://status.chromatic.com/ or contact support. + `);