A flexible error support library for Go

Overview

errors Build Status

Please see http://godoc.org/github.com/spacemonkeygo/errors for info

License

Copyright (C) 2014 Space Monkey, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Issues
  • "try" semantics

    Hello! Spacemonkey errors are awesome! Using them in my projects has resulted in a huge reduction in boilerplate and grouping things into hierarchies has made my errors and handling much cleaner!

    This is a package that attempts to take boilerplate reduction a step further, and replace frequent three-liner if err := whatever(); err != nil { return err } error handling blocks and replace them with... well, zero liners, by using panics instead. To make this feel cozy, this try package makes semantics that feel like try/catch semantics in other languages, and makes it easy to use spacemonkey error type hierarchies to trigger different handling paths. The example test functions in the PR should be pretty good demonstrations of how the syntax works.

    Panics aren't for everybody (or every situation), I know. This would represent a totally optional way to use spacemonkey errors, and so is isolated off in a sub-package. If a project is happy on the path of error returns, they'll have no reason to ever import the try package. And indeed, return-style errors are still often a good idea in many situations ('specially around concurrent work, where they're effectively required for channel/cross-goroutine reporting, even if the majority of the program is using panics and try within individual goroutines) -- so there's some package docs that attempt to highlight that, and it's purposefully easy to use the CatchAll system to flip panics back into return-style errors. Another school of thought has panics as being valid within packages, but impolite to expose across package boundaries (stdlib encoding libraries are known for doing this internally), and try should be totally easy to use like that, too.

    I've been incubating this in usage in some projects for a while now (as you can see from the commit timestamps...) and it's been working pretty well, so I thought I'd share and see if anyone thinks this is an interesting enough pattern to upstream :D

    opened by warpfork 0
Owner
Space Monkey Go
Space Monkey Go projects
Space Monkey Go
Wraps the normal error and provides an error that is easy to use with net/http.

Go HTTP Error Wraps the normal error and provides an error that is easy to use with net/http. Install go get -u github.com/cateiru/go-http-error Usage

Yuto Watanabe 0 Dec 20, 2021
A comprehensive error handling library for Go

Highlights The errorx library provides error implementation and error-related utilities. Library features include (but are not limited to): Stack trac

Joom 879 Jul 31, 2022
Reduce debugging time while programming Go. Use static and stack-trace analysis to determine which func call causes the error.

Errlog: reduce debugging time while programming Introduction Use errlog to improve error logging and speed up debugging while you create amazing code

Martin Joly 407 Jul 27, 2022
Simple error handling primitives

errors Package errors provides simple error handling primitives. go get github.com/pkg/errors The traditional error handling idiom in Go is roughly ak

null 7.8k Aug 4, 2022
A drop-in replacement for Go errors, with some added sugar! Unwrap user-friendly messages, HTTP status code, easy wrapping with multiple error types.

Errors Errors package is a drop-in replacement of the built-in Go errors package with no external dependencies. It lets you create errors of 11 differ

Kamaleshwar 42 May 18, 2022
A Go (golang) package for representing a list of errors as a single error.

go-multierror go-multierror is a package for Go that provides a mechanism for representing a list of error values as a single error. This allows a fun

HashiCorp 1.7k Aug 11, 2022
Error tracing and annotation.

errors -- import "github.com/juju/errgo" The errors package provides a way to create and diagnose errors. It is compatible with the usual Go error idi

Juju 228 Jun 18, 2022
A powerful, custom error package for Go

custom-error-go A powerful, custom error package for Go Detailed explanation: https://medium.com/codealchemist/error-handling-in-go-made-more-powerful

Abhinav Bhardwaj 12 Apr 19, 2022
Declarative error handling for Go.

ErrorFlow Declarative error handling for Go. Motivation Reading list: Don't defer Close() on writable files Error Handling — Problem Overview Proposal

Serhiy T 8 Mar 3, 2022
Generic error handling with panic, recover, and defer.

Generic error handling with panic, recover, and defer.

Marcos César de Oliveira 20 Apr 18, 2022
Go extract error codes

go-extract-error-codes Overview This library helps to extract possible error codes from configured go-restful applications quality level: PoC High Lev

AccelByte Inc 0 Nov 24, 2021
brief: a piece of error handling codelet

brief a piece of error handling codelet. this code only demonstrates how to hide sql.ErrNoRows to the caller. the Get() method defined in the pkg/proj

null 0 Oct 30, 2021
Error interface wrappers for Google's errdetails protobuf types, because they're handy as heck and I want to use them more

Error interface wrappers for Google's errdetails protobuf types, because they're handy as heck and I want to use them more

Claudia Hardman 1 Nov 18, 2021
Just another error handling primitives for golang

errors Just another error handling primitives for golang Install go install github.com/WAY29/[email protected] Usage New error and print error context Th

Longlone 5 Feb 19, 2022
ApolloError compliant error function for gqlgen

gqlgen-apollo-error ApolloError compliant error function for gqlgen Installation $ go get -u github.com/s-ichikawa/gqlgen-apollo-error Quickstart Retu

Shingo Ichikawa 1 Nov 19, 2021
Golang advanced error usage with stack tracing

UhOh Golang advanced error usage with stack tracing uhoh consists of 3 parts: Original error Description of error Stack trace File Function Line Usage

Brian Voelker 3 Mar 30, 2022
🥷 CError (Custom Error Handling)

?? CError (Custom Error Handling) Installation Via go packages: go get github.com/rozturac/cerror Usage Here is a sample CError uses: import ( "gi

Rıdvan ÖZTURAÇ 2 May 18, 2022
Errors - A lib for handling error gracefully in Go

?? Errors Errors 是一个用于优雅地处理 Go 中错误的库。 Read me in English ??‍ 功能特性 优雅地处理 error,嗯,

水不要鱼 1 Jan 17, 2022
Simple, intuitive and effective error handling for Go

Error Handling with eluv-io/errors-go The package eluv-io/errors-go makes Go error handling simple, intuitive and effective. err := someFunctionThatCa

Eluvio 0 Jan 19, 2022