You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there is an error in my ruby script, app_ruby prints exception message without a stack trace, like this:
Dec 14 16:25:17 servername /usr/sbin/kamailio[24313]: ERROR: app_ruby [app_ruby_api.c:105]: app_ruby_print_last_exception(): exception: wrong number of arguments (1 for 2..3)
Dec 14 16:25:17 servername /usr/sbin/kamailio[24313]: ERROR: app_ruby [app_ruby_api.c:1078]: app_ruby_run_ex(): ruby exception (6) on callback for: ksr_request_route (res type: 17)
Altough this message tells what is the error, it doesn't tell where the error happened, so it's hard to find the source of the problem.
In ruby, exceptions have backtrace() method returning stack trace as an array of strings. It would be really helpful if app_ruby also call this method and append its result to error message.
def some_method(param1, param2)
end
def ksr_request_route
some_method(1)
end
Expected behavior
Dec 14 16:46:24 servername /usr/sbin/kamailio[24314]: ERROR: <core> [core/kemi.c:87]: sr_kemi_core_err(): wrong number of arguments (1 for 2): /etc/kamailio/ruby/routes.rb:1:in `some_method'
/etc/kamailio/ruby/routes.rb:4:in `ksr_request_route'
Actual observed behavior
Dec 14 16:45:42 servername /usr/sbin/kamailio[24311]: ERROR: app_ruby [app_ruby_api.c:105]: app_ruby_print_last_exception(): exception: wrong number of arguments (1 for 2)
Equivalent ruby code would be (this code is not idiomatic, my aim is to provide C-like ruby code):
def some_error_generating_method
method_taking_two_params(1)
rescue => exception
message = exception.to_s() + "\n"
stack_trace = exception.backtrace()
for line in stack_trace
message = message + line + "\n"
end
print(message)
end
If someone can propose a pull request for this feature, I will happily merge it. Right now, I am not sure when I will get some time to look deeper at it.
Description
Hello,
When there is an error in my ruby script, app_ruby prints exception message without a stack trace, like this:
Altough this message tells what is the error, it doesn't tell where the error happened, so it's hard to find the source of the problem.
In ruby, exceptions have backtrace() method returning stack trace as an array of strings. It would be really helpful if app_ruby also call this method and append its result to error message.
Reproduction
in kamailio.cfg
in /etc/kamailio/ruby/routes.rb
Expected behavior
Actual observed behavior
Possible Solutions
Relevant code seem to be here: https://github.com/kamailio/kamailio/blob/master/src/modules/app_ruby/app_ruby_api.c#L98
I found example C code to print stack trace here but couldn't figure out how to integrate to app_ruby: http://zoo-project.org/svn/trunk/zoo-project/zoo-kernel/service_internal_ruby.c
Equivalent ruby code would be (this code is not idiomatic, my aim is to provide C-like ruby code):
Additional Information
kamailio -v
Centos 7.2 64bit
The text was updated successfully, but these errors were encountered: