on_error

Function on_error 

Source
pub fn on_error(attr: TokenStream, item: TokenStream) -> TokenStream
Expand description

Entry point for the on_error attribute macro.

Usage: #[on_error(self.poison_and_cleanup())]

This wraps methods that return Result<_, E> to run cleanup code on error. For methods returning Result<&mut Self, E>, it properly handles the borrow by discarding the returned reference and returning a fresh Ok(self).

The macro generates two methods:

  • __method_name_inner: contains the original body
  • method_name: wrapper that calls inner and handles errors