The Wayback Machine - https://web.archive.org/web/20201111163326/https://github.com/5anthosh/oops
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

oops 🙊 GoDoc Go Report Card

oops makes errors in Go traceable. It provides traceback function to get more information when you return error from the function

The convention says that an error should either be handled (whatever that means) or returned to the caller. But with more abstraction, it is difficult to find where the error got originated so Traceable function returns error with more information

Example

package main

import (
	"errors"

	"github.com/5anthosh/oops"
)

func main() {
	err := func1().(*oops.Error)
	println(err.Skip(1).Error())
}

func func1() error {
	return func2()
}

func func2() error {
	return func3()
}

func func3() error {
	return oops.T(errors.New("dummy one")).Info("this is just testing")
}

Run the program

$ go run test.go
🔴  Error : dummy one
ℹ️   Info  : this is just testing
         at main.func3 line 23 Desktop/Files/test.go
         at main.func2 line 19 Desktop/Files/test.go
         at main.func1 line 15 Desktop/Files/test.go
         at main.main line 10 Desktop/Files/test.go

About

Let's make errors in Go traceable

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.