@@ -41,8 +41,8 @@ pub fn into_io_error<E: Into<anyhow::Error>>(err: E) -> std::io::Error {
4141}
4242
4343/// Helper function for `log_error` and `log_warning`.
44- #[ inline]
4544#[ track_caller]
45+ #[ inline]
4646fn flatten_anyhow_error < E : Borrow < anyhow:: Error > > ( error : E ) -> String {
4747 let error = error. borrow ( ) ;
4848
@@ -57,8 +57,8 @@ fn flatten_anyhow_error<E: Borrow<anyhow::Error>>(error: E) -> String {
5757/// This follows the existing convention in the codebase that joins errors using em dashes.
5858/// For example, an error "Invalid transaction" with a cause "Proof failed" would be logged
5959/// as "Invalid transaction — Proof failed".
60- #[ inline]
6160#[ track_caller]
61+ #[ inline]
6262pub fn log_error < E : Borrow < anyhow:: Error > > ( error : E ) {
6363 tracing:: error!( "{}" , flatten_anyhow_error( error) ) ;
6464}
@@ -68,17 +68,17 @@ pub fn log_error<E: Borrow<anyhow::Error>>(error: E) {
6868/// This follows the existing convention in the codebase that joins errors using em dashes.
6969/// For example, an error "Invalid transaction" with a cause "Proof failed" would be logged
7070/// as "Invalid transaction — Proof failed".
71- #[ inline]
7271#[ track_caller]
72+ #[ inline]
7373pub fn log_warning < E : Borrow < anyhow:: Error > > ( error : E ) {
7474 tracing:: warn!( "{}" , flatten_anyhow_error( error) ) ;
7575}
7676
7777/// Displays an `anyhow::Error`'s main error and its error chain to stderr.
7878///
7979/// This can be used to show a "pretty" error to the end user.
80- #[ inline]
8180#[ track_caller]
81+ #[ inline]
8282pub fn display_error < E : Borrow < anyhow:: Error > > ( error : E ) {
8383 let error = error. borrow ( ) ;
8484 eprintln ! ( "⚠️ {error}" ) ;
@@ -125,24 +125,24 @@ pub trait LoggableError {
125125
126126impl < E : Into < anyhow:: Error > > LoggableError for E {
127127 /// Log the error with the given context and log level `ERROR`.
128- #[ inline]
129128 #[ track_caller]
129+ #[ inline]
130130 fn log_error < S : Send + Sync + Display + ' static > ( self , context : S ) {
131131 let err: anyhow:: Error = self . into ( ) ;
132132 log_error ( err. context ( context) ) ;
133133 }
134134
135135 /// Log the error with the given context and log level `WARNING`.
136- #[ inline]
137136 #[ track_caller]
137+ #[ inline]
138138 fn log_warning < S : Send + Sync + Display + ' static > ( self , context : S ) {
139139 let err: anyhow:: Error = self . into ( ) ;
140140 log_warning ( err. context ( context) ) ;
141141 }
142142
143143 /// Log the error with the given context and log level `DEBUG`.
144- #[ inline]
145144 #[ track_caller]
145+ #[ inline]
146146 fn log_debug < S : Send + Sync + Display + ' static > ( self , context : S ) {
147147 let err: anyhow:: Error = self . into ( ) ;
148148 log_warning ( err. context ( context) ) ;
@@ -183,6 +183,7 @@ impl<T> PrettyUnwrap for anyhow::Result<T> {
183183 type Inner = T ;
184184
185185 #[ track_caller]
186+ #[ inline]
186187 fn pretty_unwrap ( self ) -> Self :: Inner {
187188 match self {
188189 Ok ( result) => result,
@@ -198,8 +199,8 @@ impl<T> PrettyUnwrap for anyhow::Result<T> {
198199/// In debug mode, it prints to stderr using the format: "VM safely halted at {location}: {halt message}".
199200///
200201/// Note: For this to work as expected, panics must be set to `unwind` during compilation (default), and the closure cannot invoke any async code that may potentially execute in a different OS thread.
201- #[ inline]
202202#[ track_caller]
203+ #[ inline]
203204pub fn try_vm_runtime < R , F : FnMut ( ) -> R > ( f : F ) -> Result < R , Box < dyn Any + Send > > {
204205 // Perform the operation that may panic.
205206 let result = std:: panic:: catch_unwind ( panic:: AssertUnwindSafe ( f) ) ;
@@ -234,6 +235,7 @@ pub fn try_vm_runtime<R, F: FnMut() -> R>(f: F) -> Result<R, Box<dyn Any + Send>
234235}
235236
236237/// `catch_unwind` calls the given closure `f` and, if `f` panics, returns the panic message and backtrace.
238+ #[ inline]
237239pub fn catch_unwind < R , F : FnMut ( ) -> R > ( f : F ) -> Result < R , ( String , Backtrace ) > {
238240 // Perform the operation that may panic.
239241 std:: panic:: catch_unwind ( panic:: AssertUnwindSafe ( f) ) . map_err ( |_| {
0 commit comments