2525
2626#include " async_wrap-inl.h"
2727#include " env-inl.h"
28+ #include " node_errors.h"
2829#include " node_external_reference.h"
2930#include " threadpoolwork-inl.h"
3031#include " util-inl.h"
@@ -271,6 +272,8 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
271272 CHECK_EQ (unreported_allocations_, 0 );
272273 }
273274
275+ Environment* env () const { return this ->ThreadPoolWork ::env (); }
276+
274277 void Close () {
275278 if (write_in_progress_) {
276279 pending_close_ = true ;
@@ -694,7 +697,11 @@ class BrotliCompressionStream final :
694697 static_cast <CompressionStream<CompressionContext>*>(wrap));
695698 if (err.IsError ()) {
696699 wrap->EmitError (err);
697- args.GetReturnValue ().Set (false );
700+ // TODO(addaleax): Sometimes we generate better error codes in C++ land,
701+ // e.g. ERR_BROTLI_PARAM_SET_FAILED -- it's hard to access them with
702+ // the current bindings setup, though.
703+ THROW_ERR_ZLIB_INITIALIZATION_FAILED (wrap->env (),
704+ " Initialization failed" );
698705 return ;
699706 }
700707
@@ -708,12 +715,11 @@ class BrotliCompressionStream final :
708715 err = wrap->context ()->SetParams (i, data[i]);
709716 if (err.IsError ()) {
710717 wrap->EmitError (err);
711- args.GetReturnValue ().Set (false );
718+ THROW_ERR_ZLIB_INITIALIZATION_FAILED (wrap->env (),
719+ " Initialization failed" );
712720 return ;
713721 }
714722 }
715-
716- args.GetReturnValue ().Set (true );
717723 }
718724
719725 static void Params (const FunctionCallbackInfo<Value>& args) {
0 commit comments