@@ -58162,7 +58162,8 @@ static JSValue js_btoa(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
58162
58162
if (unlikely(c > 0xFF)) {
58163
58163
js_free(ctx, tmp);
58164
58164
JS_FreeValue(ctx, val);
58165
- return JS_ThrowTypeError(ctx, "character out of range (>255) at %zu", i);
58165
+ return JS_ThrowDOMException(ctx, "InvalidCharacterError",
58166
+ "String contains an invalid character");
58166
58167
}
58167
58168
tmp[i] = (uint8_t)c;
58168
58169
}
@@ -58215,7 +58216,8 @@ static JSValue js_atob(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
58215
58216
for (size_t i = 0; i < slen; i++) {
58216
58217
if (unlikely(p[i] & 0x80)) {
58217
58218
JS_FreeValue(ctx, val);
58218
- return JS_ThrowTypeError(ctx, "non-ASCII input");
58219
+ return JS_ThrowDOMException(ctx, "InvalidCharacterError",
58220
+ "The string to be decoded is not correctly encoded");
58219
58221
}
58220
58222
}
58221
58223
in = p;
@@ -58230,7 +58232,8 @@ static JSValue js_atob(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
58230
58232
if (unlikely(src[i] > 0x7F)) {
58231
58233
js_free(ctx, tmp);
58232
58234
JS_FreeValue(ctx, val);
58233
- return JS_ThrowTypeError(ctx, "non-ASCII input at %zu", i);
58235
+ return JS_ThrowDOMException(ctx, "InvalidCharacterError",
58236
+ "The string to be decoded is not correctly encoded");
58234
58237
}
58235
58238
tmp[i] = (uint8_t)src[i];
58236
58239
}
@@ -58266,7 +58269,9 @@ static JSValue js_atob(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
58266
58269
58267
58270
if (unlikely(err)) {
58268
58271
js_free(ctx, ostr);
58269
- return JS_ThrowTypeError(ctx, "invalid base64 input");
58272
+ return JS_ThrowDOMException(ctx, "InvalidCharacterError",
58273
+ "The string to be decoded is not correctly encoded");
58274
+
58270
58275
}
58271
58276
58272
58277
ostr->len = out_len;
0 commit comments