Skip to content

Commit

Permalink
src: pass along errors from tls object creation
Browse files Browse the repository at this point in the history
PR-URL: #25822
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
addaleax committed Feb 8, 2019
1 parent d999b55 commit 03908d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ using v8::String;
using v8::Value;

TLSWrap::TLSWrap(Environment* env,
Local<Object> obj,
Kind kind,
StreamBase* stream,
SecureContext* sc)
: AsyncWrap(env,
env->tls_wrap_constructor_function()
->NewInstance(env->context()).ToLocalChecked(),
AsyncWrap::PROVIDER_TLSWRAP),
: AsyncWrap(env, obj, AsyncWrap::PROVIDER_TLSWRAP),
SSLWrap<TLSWrap>(env, sc, kind),
StreamBase(env),
sc_(sc) {
Expand Down Expand Up @@ -160,7 +158,14 @@ void TLSWrap::Wrap(const FunctionCallbackInfo<Value>& args) {
StreamBase* stream = static_cast<StreamBase*>(stream_obj->Value());
CHECK_NOT_NULL(stream);

TLSWrap* res = new TLSWrap(env, kind, stream, Unwrap<SecureContext>(sc));
Local<Object> obj;
if (!env->tls_wrap_constructor_function()
->NewInstance(env->context())
.ToLocal(&obj)) {
return;
}

TLSWrap* res = new TLSWrap(env, obj, kind, stream, Unwrap<SecureContext>(sc));

args.GetReturnValue().Set(res->object());
}
Expand Down
1 change: 1 addition & 0 deletions src/tls_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class TLSWrap : public AsyncWrap,
static const int kSimultaneousBufferCount = 10;

TLSWrap(Environment* env,
v8::Local<v8::Object> obj,
Kind kind,
StreamBase* stream,
crypto::SecureContext* sc);
Expand Down

0 comments on commit 03908d2

Please sign in to comment.