recovery

package
v0.0.0-...-69d094b Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package recovery 提供 recover() 函数及相关功能的封装

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatchPanic

func CatchPanic(opts ...Option)

CatchPanic 捕获异常。需要用 defer 函数调用

Types

type Option

type Option func(o *option)

Option 表示额外参数

func WithCallback

func WithCallback(f PanicCallback) Option

WithCallback 出现 panic 时回调

func WithContext

func WithContext(ctx context.Context) Option

WithContext 填充 context。当拥有 ctx 时, 输出日志将会调用 ErrorContext

func WithErrorLog

func WithErrorLog() Option

WithErrorLog 表示按照默认格式默认写入错误日志

type PanicCallback

type PanicCallback func(info any, stack []caller.Caller)

PanicCallback 发生 panic 时的回调函数

Jump to

Keyboard shortcuts

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