alef 0.114.0

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
#[allow(dead_code)]
fn alef_napi_err<E: std::fmt::Display + 'static>(e: E) -> napi::Error {
    let message = e.to_string();
    let boxed: Box<dyn std::any::Any> = Box::new(e);
{% for rust_path, converter in converters %}
    let boxed = match boxed.downcast::<{{ rust_path }}>() {
        Ok(typed) => return {{ converter }}(*typed),
        Err(other) => other,
    };
{% endfor %}
    drop(boxed);
    napi::Error::new(napi::Status::GenericFailure, message)
}