Giter Site home page Giter Site logo

zerror's Introduction

ZError

Notice

v1 is deprecated, please use v2

import path : github.com/EchoUtopia/zerror/v2

example import path: github.com/EchoUtopia/zerror/examples/v2

中文文档

Terminology

  • Error Definition(zerror.Def): error definition to generate or wrap error

Features

  • Predefine errors
  • Make error code predefined and standard
  • Specified error definition Status Code for Http, Grpc and so on
  • Classify errors with groups
  • Some built-in error definitions, like zerror.NotFound, zerror.Forbidden and so on
  • List all error codes and corresponding infos(descriptions, status code, etc)
  • Extension for every error definition to do many cool things you want.

Examples:

func DoSomething()error {
    ***
    // return zerror.Internal.Wrap(errors.New(`***`))
    return zerror.BadRequest.New()
}

full examples

see in examples directory

Why is zerror made

I want errors to be clearly organized and reusable and classified in groups

I want hide errors from client and return code instead

I want to respond predefined code and log error in one line code

I want to respond with different Status Code for Grpc/Http for error generated/wrapped by zerror

so Zerror is here

zerror's People

Contributors

echoutopia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

guoceng gunsluo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.