cerror

package module
v0.0.0-...-6840be4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2017 License: BSD-2-Clause Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Err error
	// contains filtered or unexported fields
}

Error struct

Err: the error stack: the formatted stack

func (*Error) GetStack

func (e *Error) GetStack() string

Return the stack

func (*Error) Return

func (e *Error) Return(err error, msg ...interface{})

Used for returning an error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址