xpanic

package
v0.0.0-...-bcea9b7 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 6 Imported by: 0

README

Usage

It's a powerful panic handler to simplify reasoning of panics

Example

package main 

import (
	"github.com/donutloop/toolkit/xpanic"
	"log"
)

func main() {
    logF := func(format string, args ...interface{}) { log.Println(fmt.Sprintf(format, args...)) }
    panicHandler := BuildPanicHandler(logF, xpanic.CrashOnErrorDeactivated)
    defer panicHandler
    panic("hello world")
}

Documentation

Index

Constants

View Source
const (
	CrashOnErrorActivated   = true
	CrashOnErrorDeactivated = false
)

If crashOnError is set a coredump will be produced and kill program else it continues.

Variables

This section is empty.

Functions

func BuildPanicHandler

func BuildPanicHandler(errorf func(format string, args ...interface{}), crashOnError bool) func()

BuildPanicHandler builds a panic handler and verifies a none nil logger got passed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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