Skip to content

Commit c095106

Browse files
addaleaxtargos
authored andcommitted
src: pass along errors from i18n converter instantiation
PR-URL: #25734 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
1 parent deebf10 commit c095106

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/node_i18n.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ class ConverterObject : public BaseObject, Converter {
171171
Environment* env = Environment::GetCurrent(args);
172172
HandleScope scope(env->isolate());
173173

174+
Local<ObjectTemplate> t = ObjectTemplate::New(env->isolate());
175+
t->SetInternalFieldCount(1);
176+
Local<Object> obj;
177+
if (!t->NewInstance(env->context()).ToLocal(&obj)) return;
178+
174179
CHECK_GE(args.Length(), 2);
175180
Utf8Value label(env->isolate(), args[0]);
176181
int flags = args[1]->Uint32Value(env->context()).ToChecked();
@@ -190,9 +195,6 @@ class ConverterObject : public BaseObject, Converter {
190195
nullptr, nullptr, nullptr, &status);
191196
}
192197

193-
Local<ObjectTemplate> t = ObjectTemplate::New(env->isolate());
194-
t->SetInternalFieldCount(1);
195-
Local<Object> obj = t->NewInstance(env->context()).ToLocalChecked();
196198
new ConverterObject(env, obj, conv, ignoreBOM);
197199
args.GetReturnValue().Set(obj);
198200
}

0 commit comments

Comments
 (0)