handlerpanic

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package handlerpanic provides a single, shared recover-and-convert helper for the EventBus adapters (nats, rabbitmq, watermill) so a panicking modulex.EventHandler cannot crash the process. Before this package existed, each adapter reimplemented its own recover block independently, with subtly different conventions (nats.EventBus.Subscribe logged the panic and swallowed it; rabbitmq.EventBus and watermill.EventBus each converted it to an error via a separately-worded, separately-maintained closure). Centralizing the conversion here means every adapter's handler panic becomes the same kind of error, wrapped in the same message shape, with one place to change that convention in the future.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recover

func Recover(call func() error) (err error)

Recover invokes call and converts any panic inside it into a non-nil error, so a caller can treat "the handler panicked" the same way it treats "the handler returned an error" — logging it, nacking a message, or whatever else its own error path already does. If call returns an error without panicking, that error is returned unchanged. If call neither panics nor errors, Recover returns nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL