Closed javiertuya closed 1 month ago
I've located the cause: org.jsmart.zerocode.core.engine.executor.javaapi.executeWithParams
catches exceptions and rethrows a new RuntimeException with the message only.
If adding both the message and catched exception to the throw statement, the stacktrace is augmented with:
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jsmart.zerocode.core.engine.executor.javaapi.JavaMethodExecutorImpl.executeWithParams(JavaMethodExecutorImpl.java:107)
... 24 more
Caused by: java.lang.RuntimeException: INTENTIONAL EXCEPTION
at org.jsmart.zerocode.core.AddService.anInteger(AddService.java:27)
... 29 more
I will prepare a PR to fix it. @authorjapps can you please assign this to me?
I've located the cause:
org.jsmart.zerocode.core.engine.executor.javaapi.executeWithParams
catches exceptions and rethrows a new RuntimeException with the message only.If adding both the message and catched exception to the throw statement, the stacktrace is augmented with:
Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.jsmart.zerocode.core.engine.executor.javaapi.JavaMethodExecutorImpl.executeWithParams(JavaMethodExecutorImpl.java:107) ... 24 more Caused by: java.lang.RuntimeException: INTENTIONAL EXCEPTION at org.jsmart.zerocode.core.AddService.anInteger(AddService.java:27) ... 29 more
I will prepare a PR to fix it. @authorjapps can you please assign this to me?
yep, that's right. Sounds amazing. Please go ahead 🚀 Issue assigned to you now.
Also, added you now as collaborator. Click here to accept. Now, you can,
Also, can you add relevant logs as ERROR level for the DB executor, to surface important exception messages etc to the end user? This will be very helpful to Devs and SDETs to avoid rabbit holes when any problem arises.
(Ignore me if you've already thought of doing it anyways, as part of this ticket :) )
@authorjapps Great!! Thank you.
Also, can you add relevant logs as ERROR level for the DB executor, to surface important exception messages etc to the end user? This will be very helpful to Devs and SDETs to avoid rabbit holes when any problem arises.
I did, but because of this issue, I logged the messages and exceptions, which generates the needed stacktrace to locate failures (e.g. sql syntax, or invalid CSV cells). After fixing this issue, I think that only logging the error messages will be enough. I will check it.
When a java api operation throws an exception, the exception message and stacktrace are not shown as part of the scenario stacktrace, making it difficult to debug.
To reproduce:
org.jsmart.zerocode.core.AddService
and replacereturn 30
in the 'anInteger' method bythrow new RuntimeException("INTENTIONAL EXCEPTION")
unit_test_files/java_apis/02_test_json_java_service_method_no_param.json
and remove"loop": 5,
org.jsmart.zerocode.core.javamethod
Expected: Some information about the RuntimeException
INTENTIONAL EXCEPTION
, and its stacktrace should be shown Actual: It is ommited. This is the stacktrace: