Created
January 3, 2023 16:52
-
-
Save taf2/c4d4ae88b5aae9bef84e3b24d8ef984a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static VALUE callback_exception(VALUE did_raise, VALUE exception) { | |
VALUE ret = rb_funcall(exception, rb_intern("message"), 0); | |
VALUE trace = rb_funcall(exception, rb_intern("backtrace"), 0); | |
if (RB_TYPE_P(trace, T_ARRAY) && RARRAY_LEN(trace) > 0) { | |
printf("we got an exception: %s:%d\n", StringValueCStr(ret), RARRAY_LEN(trace)); | |
VALUE sep = rb_str_new_cstr("\n"); | |
VALUE trace_lines = rb_ary_join(trace, sep); | |
if (RB_TYPE_P(trace_lines, T_STRING)) { | |
printf("%s\n", StringValueCStr(trace_lines)); | |
} else { | |
printf("trace is not a string??\n"); | |
} | |
} else { | |
printf("we got an exception: %s\nno stack available\n", StringValueCStr(ret)); | |
} | |
rb_hash_aset(did_raise, rb_easy_hkey("error"), Qtrue); | |
return exception; | |
} | |
VALUE did_raise = rb_hash_new(); | |
rb_rescue(call_status_handler1, callargs, callback_exception, did_raise); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment