Sha256: 4f238ad8697459de7c17c179721ddc623b6f9bd87db0234d0e4abfd62c8c20b3

Contents?: true

Size: 929 Bytes

Versions: 10

Compression:

Stored size: 929 Bytes

Contents

#include <ruby.h>

#include "utils.h"

void save_exception(VALUE exception, const char *fmt, ...) {
    va_list args;

    va_start(args, fmt);
    VALUE message = rb_vsprintf(fmt, args);
    va_end(args);

    VALUE current_thread = rb_thread_current();
    rb_thread_local_aset(current_thread, rb_intern("prometheus_last_exception"), exception);
    rb_thread_local_aset(current_thread, rb_intern("prometheus_last_exception_message"), message);
}

NORETURN(void raise_last_exception()) {
    VALUE current_thread = rb_thread_current();
    VALUE exception = rb_thread_local_aref(current_thread, rb_intern("prometheus_last_exception"));
    VALUE message = rb_thread_local_aref(current_thread, rb_intern("prometheus_last_exception_message"));
    if (exception != Qnil) {
        rb_raise(exception, "%s", StringValueCStr(message));
    } else {
        rb_raise(rb_eRuntimeError, "no exception found in thread local");
    }
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
prometheus-client-mmap-0.7.0.beta45.7 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta45.6 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta45.5 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta45.4 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta45.3 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta45.2 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta45.1 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta44 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta43 ext/fast_mmaped_file/utils.c
prometheus-client-mmap-0.7.0.beta42 ext/fast_mmaped_file/utils.c