All Projects → hanjm → errors

hanjm / errors

Licence: MIT license
errors with paired message and caller stack frame

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to errors

go-errors
Flexible, general-purpose error handling for Go.
Stars: ✭ 17 (-10.53%)
Mutual labels:  stacktrace, errors, error-handling
Tracerr
Golang errors with stack trace and source fragments.
Stars: ✭ 646 (+3300%)
Mutual labels:  stacktrace, errors, error-handling
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (+2578.95%)
Mutual labels:  stacktrace, errors, error-handling
Bugsnag Node
[DEPRECATED] Please upgrade to our Universal JS notifier "@bugsnag/js" • https://github.com/bugsnag/bugsnag-js
Stars: ✭ 48 (+152.63%)
Mutual labels:  errors, error-handling
Panic Overlay
Displays JS errors in browsers. Shows sources. Use with any framework. 💥✨
Stars: ✭ 50 (+163.16%)
Mutual labels:  stacktrace, error-handling
Eris
eris provides a better way to handle, trace, and log errors in Go 🎆
Stars: ✭ 758 (+3889.47%)
Mutual labels:  errors, error-handling
Rollbar.js
Error tracking and logging from JS to Rollbar
Stars: ✭ 479 (+2421.05%)
Mutual labels:  errors, error-handling
Bugsnag Cocoa
Bugsnag crash reporting for iOS, macOS and tvOS apps
Stars: ✭ 167 (+778.95%)
Mutual labels:  errors, error-handling
Elmahcore
ELMAH for Net.Standard and Net.Core
Stars: ✭ 127 (+568.42%)
Mutual labels:  errors, error-handling
Whoops
PHP errors for cool kids
Stars: ✭ 12,646 (+66457.89%)
Mutual labels:  errors, error-handling
Tslog
📝 tslog - Expressive TypeScript Logger for Node.js.
Stars: ✭ 321 (+1589.47%)
Mutual labels:  stacktrace, error-handling
Bugsnag React Native
Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
Stars: ✭ 374 (+1868.42%)
Mutual labels:  stacktrace, error-handling
Bugsnag Laravel
Bugsnag notifier for the Laravel PHP framework. Monitor and report Laravel errors.
Stars: ✭ 746 (+3826.32%)
Mutual labels:  errors, error-handling
Errorx
A comprehensive error handling library for Go
Stars: ✭ 712 (+3647.37%)
Mutual labels:  errors, error-handling
Bugsnag Android Ndk
DEPRECATED - this project now lives at bugsnag/bugsnag-android
Stars: ✭ 42 (+121.05%)
Mutual labels:  errors, error-handling
Reattempt
🤞 Give your functions another chance
Stars: ✭ 570 (+2900%)
Mutual labels:  errors, error-handling
Bugsnag Go
Automatic panic monitoring for Go and Go web frameworks, like negroni, gin, and revel
Stars: ✭ 155 (+715.79%)
Mutual labels:  errors, error-handling
jsonerror
Makes Go error-handling a breeze!
Stars: ✭ 28 (+47.37%)
Mutual labels:  errors, error-handling
Bugsnag Php
Bugsnag error monitoring and crash reporting tool for PHP apps
Stars: ✭ 475 (+2400%)
Mutual labels:  errors, error-handling
Bugsnag Ruby
Bugsnag error monitoring & reporting software for rails, sinatra, rack and ruby
Stars: ✭ 211 (+1010.53%)
Mutual labels:  errors, error-handling

GoDoc Go Report Card code-coverage

errors包装error对象, 添加调用栈及附加自定义信息, 以便于从日志中快速定位问题. 特点:

  1. 相比 github.com/pkg/errors github.com/juju/errors 开销小, 只在最早出错的地方会调用runtime.Callers, 只调用一次.
  2. 对齐调用栈和附加上下文信息, 按[ 文件名:行号 函数名:message ]分行格式化输出, funcName不显示package path, fileName不显示src之前的字符. Goland等IDE可以在控制台上点击错误信息定位源码.
  3. 精简调用栈输出, 默认忽略标准库和 github.com 下的包的调用栈, 也可以用SetFilterFunc自定义一些filter, 忽略一些固定的框架的调用栈信息.

文章: Go如何优雅地错误处理(Error Handling and Go 1)

doc:

func Errorf(err error, format string, a ...interface{}) error {
 //...
}
用于包装上New/Errorf返回的error/*Err, 添加错误注释, 如 比"xx function error"更直接的错误说明、调用函数的参数值等
 			如果参数error类型不为*Err(error常量或自定义error类型或nil), 用于最早出错的地方, 会收集调用栈
 			如果参数error类型为*Err, 不会收集调用栈.
上层调用方可以通过GetInnerMost得到最里层被包装过的error常量

```go
// 示例代码1 非error常量的情况
// ExampleFunc1 调用func2 func2调用func3
// 在func3使用errors.Errorf时第一个参数传nil收集最完整的调用栈,
// 其他地方用errors.Errorf时第一个参数传上一步返回的error, 最后打log
func func1() {
	requestID := "1"
	err := func2()
	if err != nil {
		err = Errorf(err, "[%s] 123", requestID)
		log.Print(err)
		// log ouuput:
		/*
			2017/09/02 18:55:35 [errors/example.go:33:func3:unexpected param]
			[ errors/example.go:25 func2:i=3]
			[ errors/example.go:15 func1:[1] 123]
			[ errors/error_test.go:22 TestExample:]
		*/
	}
	return
}

func func2() (err error) {
	i := 3
	err = func3(i)
	if err != nil {
		return Errorf(err, "i=%d", i)
	}
	return
}

func func3(i int) (err error) {
	return Errorf(nil, "unexpected param")
}

var (
	errSomeUnexpected = errors.New("someUnexpected")
)

// 示例代码2  error常量的情况
// ExampleFunc11 调用func22 func22调用func33
// 在func33使用errors.Errorf包装error常量,收集最完整的调用栈, 最后打log
// 调用func22处可以调GetInnerMost()方法来取到最里层被包装的error常量
func func11() {
	requestID := "11"
	err := func22()
	if err != nil {
		err = Errorf(err, "[%s] 123", requestID)
		log.Print(err)
		// log output:
		/*
		2017/09/02 18:55:35 [errors/example.go:67:func33:unexpected param err:someUnexpected]
		[ errors/example.go:56 func22:i=3]
		[ errors/example.go:46 func11:[11] 123]
		[ errors/error_test.go:26 TestExample2:]
		*/
	}
	return
}

func func22() (err error) {
	i := 3
	err = func33(i)
	if err != nil {
		if err2, ok := err.(*Err); ok && err2.Inner() == errSomeUnexpected {
			fmt.Printf("==\n识别到上一步的std error:%s\n==\n", err2.Inner())
		}
		return Errorf(err, "i=%d", i)
	}
	return
}

func func33(i int) (err error) {
	return Errorf(errSomeUnexpected, "unexpected param")
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].