panicx

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package panicx contains utilities for providing meaningful contexts to panics that occur with the engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnrichUnexpectedMessage

func EnrichUnexpectedMessage(
	h configkit.RichHandler,
	iface string, method string,
	impl any,
	m dogma.Message,
	fn func(),
)

EnrichUnexpectedMessage calls fn() and converts dogma.UnexpectedMessage values to an panicx.UnexpectedMessage value to provide more context about the failure.

Types

type UnexpectedBehavior

type UnexpectedBehavior struct {
	// Handler is the non-compliant handler.
	Handler configkit.RichHandler

	// Interface is the name of the interface containing the method with the
	// unexpected behavior.
	Interface string

	// Method is the name of the method that behaved unexpectedly.
	Method string

	// Implementation is the value that implements the nominated interface.
	Implementation any

	// Message is the message that was being handled at the time, if any.
	Message dogma.Message

	// Description is a human-readable description of the behavior.
	Description string

	// Location is the engine's best attempt at pinpointing the location of the
	// unexpected behavior.
	Location location.Location
}

UnexpectedBehavior is a panic value that occurs when a handler exhibits some behavior that the engine did not expect.

Often this means it has violated the Dogma specification.

func (UnexpectedBehavior) String

func (x UnexpectedBehavior) String() string

type UnexpectedMessage

type UnexpectedMessage struct {
	// Handler is the handler that panicked.
	Handler configkit.RichHandler

	// Interface is the name of the interface containing the method that the
	// controller called resulting in the panic.
	Interface string

	// Implementation is the value that implements the nominated interface.
	Implementation any

	// Method is the name of the method that the controller called resulting in
	// the panic.
	Method string

	// Message is the message that caused the handler to panic.
	Message dogma.Message

	// PanicLocation is the location of the function that panicked, if known.
	PanicLocation location.Location
}

UnexpectedMessage is a panic value that provides more context when a handler panics with a dogma.UnexpectedMessage value.

func (UnexpectedMessage) String

func (x UnexpectedMessage) String() string

Jump to

Keyboard shortcuts

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