@@ -66,7 +66,6 @@ NAN_SETTER({{ cppClassName }}::Set{{ field.cppFunctionName }}) {
6666
6767 {%each field.args |argsInfo as arg %}
6868 baton->{{ arg.name }} = {{ arg.name }};
69-
7069 {%endeach%}
7170 baton->req .data = baton;
7271 baton->done = false ;
@@ -78,7 +77,7 @@ NAN_SETTER({{ cppClassName }}::Set{{ field.cppFunctionName }}) {
7877 }
7978
8079 {%each field|returnsInfo true false as _return %}
81- {{ _return.name }} = baton->{{ _return.name }};
80+ * {{ _return.name }} = * baton->{{ _return.name }};
8281 {%endeach%}
8382
8483 return baton->result ;
@@ -116,20 +115,21 @@ void {{ cppClassName }}::{{ field.name }}_asyncAfter(uv_work_t* req, int status)
116115 {%endeach%}
117116 };
118117
118+ TryCatch tryCatch;
119119 Local<Value> result = Local<Value>::New (Function::Cast (*instance->{{ field.name }})->Call (Context::GetCurrent ()->Global (), {{ field.args |jsArgsCount }}, argv));
120120 {{ field.returnType }} resultStatus;
121121
122122 {%each field|returnsInfo true false as _return%}
123- if (!result->IsNull () && !result->IsUndefined ()) {
123+ if (result.IsEmpty () || result->IsNativeError ()) {
124+ baton->result = {{ field.returnError }};
125+ }
126+ else if (!result->IsNull () && !result->IsUndefined ()) {
124127 {{ _return.cppClassName }}* wrapper = ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject ());
125128 wrapper->selfFreeing = false ;
126129
127130 baton->{{ _return.name }} = wrapper->GetRefValue ();
128131 baton->result = {{ field.returnSuccess }};
129132 }
130- else if (result->IsNativeError ()) {
131- baton->result = {{ field.returnError }};
132- }
133133 else {
134134 baton->result = {{ field.returnNoResults }};
135135 }
0 commit comments