mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
src: improve StringBytes error handling
PR-URL: https://github.com/nodejs/node/pull/57706 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
7d45c346bb
commit
93644d5126
18 files changed
+212
-282
No files matched your search
@@ -28,7 +28,6 @@ MaybeLocal<String> MakeString(Isolate* isolate,
|
||||
const char* data,
|
||||
size_t length,
|
||||
enum encoding encoding) {
|
||||
Local<Value> error;
|
||||
MaybeLocal<Value> ret;
|
||||
if (encoding == UTF8) {
|
||||
MaybeLocal<String> utf8_string;
|
||||
@@ -43,17 +42,11 @@ MaybeLocal<String> MakeString(Isolate* isolate,
|
||||
return utf8_string;
|
||||
}
|
||||
} else {
|
||||
ret = StringBytes::Encode(
|
||||
isolate,
|
||||
data,
|
||||
length,
|
||||
encoding,
|
||||
&error);
|
||||
ret = StringBytes::Encode(isolate, data, length, encoding);
|
||||
}
|
||||
|
||||
if (ret.IsEmpty()) {
|
||||
CHECK(!error.IsEmpty());
|
||||
isolate->ThrowException(error);
|
||||
return {};
|
||||
}
|
||||
|
||||
DCHECK(ret.IsEmpty() || ret.ToLocalChecked()->IsString());
|
||||
|
||||
Reference in new issue
Block a user