BetterErrors

package module
v0.0.0-...-6e4275c Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 3 Imported by: 0

README

BetterErrors

Overview

BetterErrors is a GoLang package that provides a more beautiful and effective way to handle and display errors in your applications. It includes functions for logging detailed error information, recovering from panics, and printing general user information.

Features

  • LogError: Log detailed error information with runtime details.
  • RecoverFromPanic: Recover from panics and log panic details.
  • PrintInfo: Print general information about the user.

Usage

Installation
go get -u github.com/9dl/BetterErrors
Example
package main

var logger = BetterErrors.NewErrorLogger()

import (
	"errors"
	"github.com/9dl/BetterErrors"
)

func main() {
	logger.SetIncludeSensitiveInfo(true)
	someFunction()
	// ... rest of your code ...
}

func someFunction()  {
	logger.LogError(errors.New("Hello!"))
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintInfo

func PrintInfo()

func RecoverFromPanic

func RecoverFromPanic()

Types

type ErrorLogger

type ErrorLogger struct {
	IncludeSensitiveInfo bool
	ExitMessage          string
}

func NewErrorLogger

func NewErrorLogger() *ErrorLogger

func (*ErrorLogger) LogError

func (logger *ErrorLogger) LogError(err error)

func (*ErrorLogger) SetExitMessage

func (logger *ErrorLogger) SetExitMessage(exitMessage string)

func (*ErrorLogger) SetIncludeSensitiveInfo

func (logger *ErrorLogger) SetIncludeSensitiveInfo(includeSensitiveInfo bool)

Jump to

Keyboard shortcuts

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