diff --git a/scripts/build-docs.ts b/scripts/build-docs.ts index 8acaf536f1ef..c5b66ebaf2db 100644 --- a/scripts/build-docs.ts +++ b/scripts/build-docs.ts @@ -1,4 +1,3 @@ -import assert from 'assert'; import lodash from 'lodash'; import type { NavTree, NavTreeItem, RecursiveChildren } from '@/types/scripts/build-docs'; @@ -106,8 +105,11 @@ function buildNavTree(navItems: Details[]) { return tree; } catch (err) { - assert(err instanceof Error); - throw new Error(`Failed to build navigation tree: ${err.message}`); + if (err instanceof Error) { + throw new Error(`Failed to build navigation tree: ${err.message}`); + } else { + throw new Error(`Failed to build navigation tree: ${err}`); + } } } @@ -132,8 +134,7 @@ const convertDocPosts = (docObject: NavTree | Details) => { return docsArray; } catch (err) { - assert(err instanceof Error); - throw new Error('Error in convertDocPosts:', err); + throw new Error('Error in convertDocPosts:', err as Error); } }; @@ -218,8 +219,7 @@ function addDocButtons(docPosts: Details[], treePosts: NavTree) { return docPost; }); } catch (err) { - assert(err instanceof Error); - throw new Error('An error occurred while adding doc buttons:', err); + throw new Error('An error occurred while adding doc buttons:', err as Error); } return structuredPosts; diff --git a/scripts/build-meetings.ts b/scripts/build-meetings.ts index 5d6842246eff..acb01ca71ed7 100644 --- a/scripts/build-meetings.ts +++ b/scripts/build-meetings.ts @@ -1,4 +1,3 @@ -import assert from 'assert'; import { writeFileSync } from 'fs'; import { google } from 'googleapis'; import { dirname, resolve } from 'path'; @@ -19,8 +18,11 @@ async function buildMeetings(writePath: string) { calendar = google.calendar({ version: 'v3', auth }); } catch (err) { - assert(err instanceof Error); - throw new Error(`Authentication failed: ${err.message}`); + if (err instanceof Error) { + throw new Error(`Authentication failed: ${err.message}`); + } else { + throw new Error(`Authentication failed: ${err}`); + } } let eventsItems; diff --git a/scripts/finance/index.ts b/scripts/finance/index.ts index 652a510ea0fd..1f1230d79e02 100644 --- a/scripts/finance/index.ts +++ b/scripts/finance/index.ts @@ -1,4 +1,3 @@ -import assert from 'assert'; import { mkdir } from 'fs/promises'; import { resolve } from 'path'; @@ -37,7 +36,10 @@ export async function buildFinanceInfoList({ await writeJSON(expensesLinkPath, expensesLinkJsonPath); } catch (err) { - assert(err instanceof Error); - throw new Error(err.message); + if (err instanceof Error) { + throw new Error(`Error in buildFinanceInfoList: ${err.message}`); + } else { + throw new Error(`Error in buildFinanceInfoList: ${err}`); + } } } diff --git a/scripts/tools/tools-object.ts b/scripts/tools/tools-object.ts index 8a2efac31c25..f48765c7634a 100644 --- a/scripts/tools/tools-object.ts +++ b/scripts/tools/tools-object.ts @@ -1,6 +1,5 @@ import Ajv from 'ajv'; import addFormats from 'ajv-formats'; -import assert from 'assert'; import axios from 'axios'; import Fuse from 'fuse.js'; @@ -127,8 +126,11 @@ async function convertTools(data: ToolsData) { return finalToolsObject; } catch (err) { - assert(err instanceof Error); - throw new Error(`Error processing tool: ${err.message}`); + if (err instanceof Error) { + throw new Error(`Error processing tool: ${err.message}`); + } else { + throw new Error(`Error processing tool: ${err}`); + } } }