From 6d811949273ae63e30612790699ce63831b3a0e4 Mon Sep 17 00:00:00 2001 From: Andrius Laurinenas Date: Wed, 29 Jan 2020 13:55:17 -0100 Subject: [PATCH] Add more context in the error message Information may be useful to locate accidentally included wide character --- src/other/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/other/utils.ts b/src/other/utils.ts index 7fe4704..96bc90b 100644 --- a/src/other/utils.ts +++ b/src/other/utils.ts @@ -12,7 +12,7 @@ export function string_to_bytes(str: string, utf8: boolean = false): Uint8Array if (++i >= len) throw new Error('Malformed string, low surrogate expected at position ' + i); c = ((c ^ 0xd800) << 10) | 0x10000 | (str.charCodeAt(i) ^ 0xdc00); } else if (!utf8 && c >>> 8) { - throw new Error('Wide characters are not allowed.'); + throw new Error('Wide characters are not allowed. At the position ' + i + ' this character was found: ' + str[i]) } if (!utf8 || c <= 0x7f) {