panic_hook

Attribute Macro panic_hook 

Source
#[panic_hook]
Expand description

Registers a function as a panic hook.

This attribute macro registers the decorated function to handle panics that occur during request processing. This macro requires the #[hyperlane(server: Server)] macro to be used to define the server instance.

§Note

If an order parameter is not specified, the hook will have a higher priority than hooks with a specified order.

§Usage

use hyperlane::*;
use hyperlane_macros::*;

#[panic_hook]
#[panic_hook(1)]
#[panic_hook("2")]
struct PanicHook;

impl ServerHook for PanicHook {
    async fn new(_ctx: &Context) -> Self {
        Self
    }

    #[epilogue_macros(response_body("panic_hook"), send)]
    async fn handle(self, ctx: &Context) {}
}

§Dependencies

This macro depends on the #[hyperlane(server: Server)] macro to define the server instance.