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; +}