Skip to content

🪳 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

GabrielHCataldo/go-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Errors Detail

Project status Go Report Card Coverage Status Open Source Helpers GoDoc License

The go-errors project came to clarify the return of errors, which are very common in Golang, thus facilitating the debugging 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, visit All examples link.

Simple example

package main

import (
    "github.com/GabrielHCataldo/go-errors/errors"
    "github.com/GabrielHCataldo/go-logger/logger"
)

func main() {
    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()
}

func simple() error {
    return errors.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 +0x64
github.com/GabrielHCataldo/go-errors/errors.New({0x1400039fd18?, 0x0?, 0x1400039fc38?})
    /Users/gabrielcataldo/Innovfor/GabrielHCataldo/go-errors/errors/errors.go:31 +0xe0
main.simple(...)
    /Users/gabrielcataldo/Innovfor/GabrielHCataldo/go-errors/_example/main.go:25
main.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 it an 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