Skip to content

90TechSAS/go-cool-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-cool-error

An tiny and beautiful error printer

Installation

First, get ryanuber/columnize:

go get github.com/ryanuber/columnize

And then, get go-cool-error:

go get github.com/90TechSAS/go-cool-error

Example

package main

import (
	"errors"
	"fmt"
	"github.com/90TechSAS/go-cool-error"
)

func main() {
	err := A()
	if err.Err != nil {
		fmt.Println(err.GetStack())
	} else {
		fmt.Println("All Good")
	}
}

func A() (e cerror.Error) {
	e = B()
	return e
}

func B() (e cerror.Error) {
	e = C()
	return e
}

func C() (e cerror.Error) {
	e.Return(errors.New("Error message #1"), []string{"Error", "message"}, 2, true)
	return e
}

Output:

Error message #1 ([Error message] 2 true)
  main.C     /tmp/cerror/examples/main.go:30
  main.B     /tmp/cerror/examples/main.go:25
  main.A     /tmp/cerror/examples/main.go:20
  main.main  /tmp/cerror/examples/main.go:1

Releases

No releases published

Packages

No packages published

Languages