@@ -234,23 +234,24 @@ inline void THROW_ERR_SQLITE_ERROR(Isolate* isolate, DatabaseSync* db) {
234234}
235235
236236bool DatabaseSync::HasPendingAuthorizerError () const {
237- return has_pending_authorizer_error_;
237+ Local<Value> error =
238+ object ()->GetInternalField (kPendingAuthorizerError ).As <Value>();
239+ return !error.IsEmpty () && !error->IsUndefined ();
238240}
239241
240242void DatabaseSync::StoreAuthorizerError (Local<Value> error) {
241- if (!has_pending_authorizer_error_) {
242- pending_authorizer_error_.Reset (env ()->isolate (), error);
243- has_pending_authorizer_error_ = true ;
243+ if (!HasPendingAuthorizerError ()) {
244+ object ()->SetInternalField (kPendingAuthorizerError , error);
244245 }
245246}
246247
247248void DatabaseSync::RethrowPendingAuthorizerError () {
248- if (has_pending_authorizer_error_ ) {
249- Isolate* isolate = env ()-> isolate ();
250- Local<Value> err = pending_authorizer_error_. Get (isolate );
251- pending_authorizer_error_. Reset ();
252- has_pending_authorizer_error_ = false ;
253- isolate->ThrowException (err );
249+ if (HasPendingAuthorizerError () ) {
250+ Local<Value> error =
251+ object ()-> GetInternalField ( kPendingAuthorizerError ). As <Value>( );
252+ object ()-> SetInternalField ( kPendingAuthorizerError ,
253+ Undefined ( env ()-> isolate ())) ;
254+ env ()-> isolate () ->ThrowException (error );
254255 }
255256}
256257
0 commit comments