You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
473 B

/// Macro to use error template to return errors
/// must pass it hb then Result
#[macro_export]
macro_rules! render_error {
($hb: expr, $e:expr) => {
match $e {
Ok(r) => r,
Err(e) => {
let data = json!({
"error": e.to_string(),
});
let body = match $hb.render("error", &data) {
Ok(r) => r,
Err(ee) => format!("error: {e}\nerror2: {ee}\n"),
};
return Ok(actix_web::HttpResponse::InternalServerError().body(body));
}
}
};
}