feat(ui): add util to extract message from a tsafe AssertionError

This commit is contained in:
psychedelicious
2024-11-08 08:01:24 +10:00
parent 6c59790a7f
commit 730fabe2de

View File

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