From e60db9e254a04b14f06606007f9da9366ddf0202 Mon Sep 17 00:00:00 2001 From: naskya Date: Wed, 12 Jun 2024 19:43:52 +0900 Subject: [PATCH] chore (macros-impl): add linebreaks to napi error reason --- packages/macro-rs/macros-impl/src/napi.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/macro-rs/macros-impl/src/napi.rs b/packages/macro-rs/macros-impl/src/napi.rs index 11d9283d5b..13e2242ab8 100644 --- a/packages/macro-rs/macros-impl/src/napi.rs +++ b/packages/macro-rs/macros-impl/src/napi.rs @@ -177,7 +177,9 @@ use quote::{quote, ToTokens}; /// #[napi_derive::napi(js_name = "integerDivide",)] /// pub fn integer_divide_napi(dividend: i64, divisor: i64) -> napi::Result { /// integer_divide(dividend, divisor) -/// .map_err(|err| napi::Error::from_reason(crate::util::error_chain::format_error(&err))) +/// .map_err(|err| napi::Error::from_reason( +/// format!("\n{}\n", crate::util::error_chain::format_error(&err)) +/// )) /// } /// # }); /// ``` @@ -248,7 +250,9 @@ pub fn napi(macro_attr: TokenStream, item: TokenStream) -> TokenStream { }; // add modifier to function call result function_call_modifiers.push(quote! { - .map_err(|err| napi::Error::from_reason(crate::util::error_chain::format_error(&err))) + .map_err(|err| napi::Error::from_reason( + format!("\n{}\n", crate::util::error_chain::format_error(&err)) + )) }); } }; @@ -382,7 +386,9 @@ crate::macro_unit_tests! { divisor: i64, ) -> napi::Result { integer_divide(dividend, divisor) - .map_err(|err| napi::Error::from_reason(crate::util::error_chain::format_error(&err))) + .map_err(|err| napi::Error::from_reason( + format!("\n{}\n", crate::util::error_chain::format_error(&err)) + )) } }