From 730fabe2def76b11e3cfd097ff239aad76ed4c0d Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 8 Nov 2024 08:01:24 +1000 Subject: [PATCH] feat(ui): add util to extract message from a tsafe AssertionError --- .../web/src/common/util/extractMessageFromAssertionError.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 invokeai/frontend/web/src/common/util/extractMessageFromAssertionError.ts diff --git a/invokeai/frontend/web/src/common/util/extractMessageFromAssertionError.ts b/invokeai/frontend/web/src/common/util/extractMessageFromAssertionError.ts new file mode 100644 index 0000000000..a6c61bb6f3 --- /dev/null +++ b/invokeai/frontend/web/src/common/util/extractMessageFromAssertionError.ts @@ -0,0 +1,6 @@ +import type { AssertionError } from 'tsafe'; + +export function extractMessageFromAssertionError(error: AssertionError): string | null { + const match = error.message.match(/Wrong assertion encountered: "(.*)"/); + return match ? (match[1] ?? null) : null; +}