Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

the most easiest way to print stacktrace for error in golang

License

NotificationsYou must be signed in to change notification settings

diemus/errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

the most easiest way to print stacktrace for error in golang

Required Go Version

golang >= 1.13

Usage

import

import"github.com/diemus/errors"

Wrap an error when you return it, then you will get an stacktrace when you print it

functest()error {err:=errors.New("test")returnerrors.Wrap(err)}functest2()error {_ ,err:=someLib.do()returnerrors.Wrap(err)}functest1(errerror) {log.Println(err)}

use Cause() to get the original error when you don't want show the full detail of stacktrace

functest2(errerror) {log.Println(errors.Cause(err))}

the other function in standard library "errors" are wrap by this library, so you can replace the standard library with this package

import"github.com/diemus/errors"functest3(errerror) {errors.New("test")errors.Is(err,err)errors.As(err,err)}

About

the most easiest way to print stacktrace for error in golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp