recover

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2018 License: MIT Imports: 0 Imported by: 1

README

Recover

CircleCI Go Report Card godoc

Package recover contains basic functions which helps to work with recover in bit pleasant way.

Installation

go get -u github.com/thepkg/recover

Usage

import "github.com/thepkg/recover"

func f1() {
  defer recover.All(func(err interface{}) {
    fmt.Printf("got error: %s", err.(error))
  })
}

func f2() {
  defer recover.Any([]error{ErrorUsernameBlank, ErrorUsernameAlreadyTaken}, func(err interface{}) {
    fmt.Printf("got error: %s", err.(error))
  })
}

Documentation

Overview

Package recover contains basic functions which helps to work with `recover` in bit pleasant way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(cb func(v interface{}))

All performs call cb function with recovered value.

func Any

func Any(errors []error, cb func(v interface{}))

Any performs call cb function with recovered value in case when recovered value exists in slice errors.

func One

func One(e error, cb func(v interface{}))

One performs call cb function with recovered value in case when recovered value equals to e.

Types

This section is empty.

Jump to

Keyboard shortcuts

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