GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - f1monkey/errs: A simple wrapper over the standard errors package to get error stack traces.

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
README.md
README.md
 
 
errs.go
errs.go
 
 
go.mod
go.mod
 
 

Repository files navigation

Errs

A simple wrapper over the standard errors package to get error stack traces.

Install

$ go get -v github.com/f1monkey/errs

Usage

package main

import (
    "errors"

    "github.com/f1monkey/errs"
)


func doSomething() error {
    // ...

    result, err := service.Do(ctx)
    if err != nil {
        return errs.Errorf("service err: %w", err) // stacktrace will be captured here
    }

    // ...
}

type stacktracer interface {
	StackTrace() []byte
}

func DoSomething() error {
    // ...

    if err := doSomething(); err != nil {
		var stacktraceErr *errs.Error
		// get stack trace, option 1: use errors.As()
		if errors.As(err, &stacktraceErr) {
			fmt.Println(stacktraceErr.StackTrace())
		}

		// get stack trace, option 2: use type assertion
		if e, ok := err.(stacktracer); ok {
			fmt.Println(e.StackTrace())
		}
	}

	// ...
}

About

A simple wrapper over the standard errors package to get error stack traces.

Topics

errorsstacktrace

Resources

Readme
Activity
Custom properties

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.