errors

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 5 Imported by: 3

README

GoDoc

errors

import "github.com/go-coldbrew/errors"

Package errors provides an implementation of golang error with stack strace information attached to it, the error objects created by this package are compatible with https://golang.org/pkg/errors/

How To Use

The simplest way to use this package is by calling one of the two functions

errors.New(...)
errors.Wrap(...)

You can also initialize custom error stack by using one of the `WithSkip` functions. `WithSkip` allows skipping the defined number of functions from the stack information.

Index

func SetBaseFilePath

func SetBaseFilePath(path string)

SetBaseFilePath sets the base file path for linking source code with reported stack information

type ErrorExt

ErrorExt is the interface that defines a error, any ErrorExt implementors can use and override errors and notifier package

type ErrorExt interface {
    Callers() []uintptr
    StackFrame() []StackFrame
    //Cause returns the original error object that caused this error
    Cause() error
    //GRPCStatus allows ErrorExt to be treated as a GRPC Error
    GRPCStatus() *grpcstatus.Status
    // contains filtered or unexported methods
}
func New
func New(msg string) ErrorExt

New creates a new error with stack information

func NewWithSkip
func NewWithSkip(msg string, skip int) ErrorExt

NewWithSkip creates a new error skipping the number of function on the stack

func NewWithSkipAndStatus
func NewWithSkipAndStatus(msg string, skip int, status *grpcstatus.Status) ErrorExt

NewWithSkipAndStatus creates a new error skipping the number of function on the stack and GRPC status

func NewWithStatus
func NewWithStatus(msg string, status *grpcstatus.Status) ErrorExt

NewWithStatus creates a new error with statck information and GRPC status

func Wrap
func Wrap(err error, msg string) ErrorExt

Wrap wraps an existing error and appends stack information if it does not exists

func WrapWithSkip
func WrapWithSkip(err error, msg string, skip int) ErrorExt

WrapWithSkip wraps an existing error and appends stack information if it does not exists skipping the number of function on the stack

func WrapWithSkipAndStatus
func WrapWithSkipAndStatus(err error, msg string, skip int, status *grpcstatus.Status) ErrorExt

WrapWithSkip wraps an existing error and appends stack information if it does not exists skipping the number of function on the stack along with GRPC status

func WrapWithStatus
func WrapWithStatus(err error, msg string, status *grpcstatus.Status) ErrorExt

Wrap wraps an existing error and appends stack information if it does not exists along with GRPC status

type NotifyExt

NotifyExt is the interface definition for notifier related options

type NotifyExt interface {
    ShouldNotify() bool
    Notified(status bool)
}

type StackFrame

StackFrame represents the stackframe for tracing exception

type StackFrame struct {
    File string `json:"file"`
    Line int    `json:"line"`
    Func string `json:"function"`
}

Generated by gomarkdoc

Documentation

Overview

Package errors provides an implementation of golang error with stack strace information attached to it, the error objects created by this package are compatible with https://golang.org/pkg/errors/

How To Use

The simplest way to use this package is by calling one of the two functions

errors.New(...)
errors.Wrap(...)

You can also initialize custom error stack by using one of the `WithSkip` functions. `WithSkip` allows skipping the defined number of functions from the stack information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetBaseFilePath

func SetBaseFilePath(path string)

SetBaseFilePath sets the base file path for linking source code with reported stack information

Types

type ErrorExt

type ErrorExt interface {
	error
	Callers() []uintptr
	StackFrame() []StackFrame
	//Cause returns the original error object that caused this error
	Cause() error
	//GRPCStatus allows ErrorExt to be treated as a GRPC Error
	GRPCStatus() *grpcstatus.Status
}

ErrorExt is the interface that defines a error, any ErrorExt implementors can use and override errors and notifier package

func New

func New(msg string) ErrorExt

New creates a new error with stack information

func NewWithSkip

func NewWithSkip(msg string, skip int) ErrorExt

NewWithSkip creates a new error skipping the number of function on the stack

func NewWithSkipAndStatus

func NewWithSkipAndStatus(msg string, skip int, status *grpcstatus.Status) ErrorExt

NewWithSkipAndStatus creates a new error skipping the number of function on the stack and GRPC status

func NewWithStatus

func NewWithStatus(msg string, status *grpcstatus.Status) ErrorExt

NewWithStatus creates a new error with statck information and GRPC status

func Wrap

func Wrap(err error, msg string) ErrorExt

Wrap wraps an existing error and appends stack information if it does not exists

func WrapWithSkip

func WrapWithSkip(err error, msg string, skip int) ErrorExt

WrapWithSkip wraps an existing error and appends stack information if it does not exists skipping the number of function on the stack

func WrapWithSkipAndStatus

func WrapWithSkipAndStatus(err error, msg string, skip int, status *grpcstatus.Status) ErrorExt

WrapWithSkip wraps an existing error and appends stack information if it does not exists skipping the number of function on the stack along with GRPC status

func WrapWithStatus

func WrapWithStatus(err error, msg string, status *grpcstatus.Status) ErrorExt

Wrap wraps an existing error and appends stack information if it does not exists along with GRPC status

type NotifyExt

type NotifyExt interface {
	ShouldNotify() bool
	Notified(status bool)
}

NotifyExt is the interface definition for notifier related options

type StackFrame

type StackFrame struct {
	File string `json:"file"`
	Line int    `json:"line"`
	Func string `json:"function"`
}

StackFrame represents the stackframe for tracing exception

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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