iotjs icon indicating copy to clipboard operation
iotjs copied to clipboard

Show correct source position when assert failure

Open seanshpark opened this issue 11 years ago • 4 comments

current message for assert failure is always same position

src/iotjs_binding.cpp:329: iotjs::JObject iotjs::JObject::Call(iotjs::JObject&, iotjs::JArgList&): Assertion `is_ok' failed.
Aborted (core dumped)

need to fix this to show real position.

seanshpark avatar Jun 10 '15 07:06 seanshpark

Actually, it is the place where assertion failed.

  bool is_ok = jerry_api_call_function(_obj_val.v_object,
                                       this_obj_p,
                                       &res,
                                       val_args,
                                       val_argv);
  IOTJS_ASSERT(is_ok);

jerry_api_call_function() returns false when there was something wrong executing the function. I think we can handle this more gracefully by treating the exception. Current implementation returns only JObject that can not hold additional information - wether it is exception or not. I'm planing to extend our binding functionality for handling such exception by introducing new return type something like:

class JResult {
  JObject _object;
  bool _is_error;
}

ILyoan avatar Jun 10 '15 08:06 ILyoan

ok, good.

seanshpark avatar Jun 10 '15 09:06 seanshpark

#91 landed. Now IoT.js throw exception when something goes wrong but unfortunately, jerry does not provide exact position where the error occurred.

ILyoan avatar Jun 19 '15 03:06 ILyoan

closing. JerryScript also shows error location properly

yichoi avatar Sep 07 '16 01:09 yichoi