Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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
Appearance settings

🪳 Lib written in Go, facilitates and improves the visibility of errors that occur in your project, for better bug debugging, we have a robust structure and following the standard error interface, we have message, file, line, stack trace, cause everything for your project.

License

NotificationsYou must be signed in to change notification settings

GabrielHCataldo/go-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project statusGo Report CardCoverage StatusOpen Source HelpersGoDocLicense

The go-errors project came to clarify the return of errors, which are very common in Golang, thus facilitating thedebugging your projects.

Installation

Use go get.

go get github.com/GabrielHCataldo/go-errors

Then import the go-errors package into your own code.

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

Usability and documentation

IMPORTANT: Always check the documentation in the structures and functions fields.For more details on the examples, visitAll examples link.

Simple example

package mainimport ("github.com/GabrielHCataldo/go-errors/errors""github.com/GabrielHCataldo/go-logger/logger")funcmain() {err:=simple()logger.Info("simple err:",err)logger.Info("simple err msg:",errors.Details(err).GetMessage())logger.Info("simple err file:",errors.Details(err).GetFile())logger.Info("simple err line:",errors.Details(err).GetLine())logger.Info("simple err func:",errors.Details(err).GetFuncName())errors.Details(err).PrintCause()errors.Details(err).PrintStackTrace()}funcsimple()error {returnerrors.New("error by message with any value",2,true)}

Output:

[INFO 2024/01/26 10:16:38] _example/main.go:12: simple err: [CAUSE]: (_example/main.go:25) simple: error by message with any value 2 true [STACK]:goroutine 1 [running]:runtime/debug.Stack()    /Users/gabrielcataldo/go/go1.21.3/src/runtime/debug/stack.go:24 +0x64github.com/GabrielHCataldo/go-errors/errors.New({0x1400039fd18?, 0x0?, 0x1400039fc38?})    /Users/gabrielcataldo/Innovfor/GabrielHCataldo/go-errors/errors/errors.go:31 +0xe0main.simple(...)    /Users/gabrielcataldo/Innovfor/GabrielHCataldo/go-errors/_example/main.go:25main.main()    /Users/gabrielcataldo/Innovfor/GabrielHCataldo/go-errors/_example/main.go:11 +0x88[INFO 2024/01/26 10:16:38] _example/main.go:12: simple err msg: error by message with any value 2 true[INFO 2024/01/26 10:16:38] _example/main.go:13: simple err file: _example/main.go[INFO 2024/01/26 10:16:38] _example/main.go:14: simple err line: 25[INFO 2024/01/26 10:16:38] _example/main.go:15: simple err func: simple[ERROR 2024/01/26 10:16:38] _example/main.go:16: (_example/main.go:25) simple: error by message with any value 2 true[ERROR 2024/01/26 10:16:38] _example/main.go:17: goroutine 1 [running]:

How to contribute

Make a pull request, or if you find a bug, open itan Issues.

License

Distributed under MIT license, see the license file within the code for more details.

About

🪳 Lib written in Go, facilitates and improves the visibility of errors that occur in your project, for better bug debugging, we have a robust structure and following the standard error interface, we have message, file, line, stack trace, cause everything for your project.

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp