Code Monkey home page Code Monkey logo

gabrielhcataldo / go-errors Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 54 KB

🪳 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.

Home Page: https://pkg.go.dev/github.com/GabrielHCataldo/go-errors/errors

License: MIT License

Go 100.00%
debug debugging error errors go-debug go-error-handler go-error-handling go-errors

go-errors's Introduction

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.

go-errors's People

Contributors

gabrielhcataldo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.