Skip to content

Commit 3794fde

Browse files
textdecoder throws Napi::Error (#139)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent fe50276 commit 3794fde

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

Polyfills/TextDecoder/Source/TextDecoder.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ namespace
3535
auto encoding = info[0].As<Napi::String>().Utf8Value();
3636
if (encoding != "utf-8" && encoding != "UTF-8")
3737
{
38-
Napi::Error::New(info.Env(), "TextDecoder: unsupported encoding '" + encoding + "', only 'utf-8' is supported")
39-
.ThrowAsJavaScriptException();
38+
throw Napi::Error::New(Env(), "TextDecoder: unsupported encoding '" + encoding + "', only 'utf-8' is supported");
4039
}
4140
}
4241
}
@@ -75,9 +74,7 @@ namespace
7574
}
7675
else
7776
{
78-
Napi::TypeError::New(info.Env(), "TextDecoder.decode: input must be a BufferSource (ArrayBuffer or TypedArray)")
79-
.ThrowAsJavaScriptException();
80-
return info.Env().Undefined();
77+
throw Napi::TypeError::New(Env(), "TextDecoder.decode: input must be a BufferSource (ArrayBuffer or TypedArray)");
8178
}
8279

8380
return Napi::String::New(info.Env(), data);

0 commit comments

Comments
 (0)