Skip to content

Commit 730fabe

Browse files
feat(ui): add util to extract message from a tsafe AssertionError
1 parent 6c59790 commit 730fabe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { AssertionError } from 'tsafe';
2+
3+
export function extractMessageFromAssertionError(error: AssertionError): string | null {
4+
const match = error.message.match(/Wrong assertion encountered: "(.*)"/);
5+
return match ? (match[1] ?? null) : null;
6+
}

0 commit comments

Comments
 (0)