@@ -140,6 +140,65 @@ void {{ cppClassName }}::{{ cppFunctionName }}Worker::HandleOKCallback() {
140140 free ((void *)baton->error ->message );
141141 free ((void *)baton->error );
142142 } else if (baton->error_code < 0 ) {
143+ std::queue< Local<v8::Value> > workerArguments;
144+ {%each args|argsInfo as arg %}
145+ {%if not arg.isReturn %}
146+ {%if not arg.isSelf %}
147+ {%if not arg.isCallbackFunction %}
148+ workerArguments.push (Nan::New (GetFromPersistent (" {{ arg.name }}" )));
149+ {%endif%}
150+ {%endif%}
151+ {%endif%}
152+ {%endeach%}
153+ while (!workerArguments.empty ()) {
154+ Local<v8::Value> node = workerArguments.front ();
155+ workerArguments.pop ();
156+
157+ if (
158+ !node->IsObject ()
159+ || node->IsArray ()
160+ || node->IsBooleanObject ()
161+ || node->IsDate ()
162+ || node->IsFunction ()
163+ || node->IsNumberObject ()
164+ || node->IsRegExp ()
165+ || node->IsStringObject ()
166+ ) {
167+ continue ;
168+ }
169+
170+ Local<v8::Object> nodeObj = node->ToObject ();
171+ Local<v8::Value> checkValue = nodeObj->GetHiddenValue (Nan::New (" NodeGitPromiseError" ).ToLocalChecked ());
172+
173+ if (!checkValue.IsEmpty ()) {
174+ Local<v8::Value> argv[1 ] = {
175+ checkValue->ToObject ()
176+ };
177+ callback->Call (1 , argv);
178+ return ;
179+ }
180+
181+ Local<v8::Array> properties = nodeObj->GetPropertyNames ();
182+ for (unsigned int propIndex = 0 ; propIndex < properties->Length (); ++propIndex) {
183+ Local<v8::String> propName = properties->Get (propIndex)->ToString ();
184+ Local<v8::Value> nodeToQueue = Nan::New (nodeObj->Get (propName));
185+ if (!nodeToQueue->IsUndefined ()) {
186+ workerArguments.push (nodeToQueue);
187+ }
188+ }
189+ }
190+ // Local<v8::Object> arguments = GetFromPersistent("opts")->ToObject();
191+ // Local<v8::Object> moreTest = test->Get(Nan::New("callbacks").ToLocalChecked())->ToObject();
192+ //
193+ // Local<Value> argmoo[1]; // MSBUILD won't assign an array of length 0
194+ // Local<v8::Object> promise = moreTest->GetHiddenValue(Nan::New("what_if_i_was_error").ToLocalChecked())->ToObject();
195+ // Nan::Callback* isFulfilledFn = new Nan::Callback(Nan::Get(promise, Nan::New("reason").ToLocalChecked()).ToLocalChecked().As<Function>());
196+ // Local<v8::String> test2 = isFulfilledFn->Call(promise, 0, argmoo)->ToString();
197+ // v8::String::Utf8Value param1(test2);
198+
199+ // convert it to string
200+ // std::string foo = std::string(*param1);
201+ // std::cout << foo << std::endl;
143202 Local<v8::Object> err = Nan::Error (" Method {{ jsFunctionName }} has thrown an error." )->ToObject ();
144203 err->Set (Nan::New (" errno" ).ToLocalChecked (), Nan::New (baton->error_code ));
145204 Local<v8::Value> argv[1 ] = {
0 commit comments