errors - ActiveState ActiveGo 1.8

Package errors

import ""

Overview ▾

Package errors provides a way to return detailed information for an RPC request error. The error is normally JSON encoded.

func BadRequest

func BadRequest(id, format string, a ...interface{}) error

BadRequest generates a 400 error.

func Forbidden

func Forbidden(id, format string, a ...interface{}) error

Forbidden generates a 403 error.

func InternalServerError

func InternalServerError(id, format string, a ...interface{}) error

InternalServerError generates a 500 error.

func New

func New(id, detail string, code int32) error

New generates a custom error.

func NotFound

func NotFound(id, format string, a ...interface{}) error

NotFound generates a 404 error.

func Unauthorized

func Unauthorized(id, format string, a ...interface{}) error

Unauthorized generates a 401 error.

type Error

Error implements the error interface.

type Error struct {
    Id     string `json:"id"`
    Code   int32  `json:"code"`
    Detail string `json:"detail"`
    Status string `json:"status"`

func Parse

func Parse(err string) *Error

Parse tries to parse a JSON string into an error. If that fails, it will set the given string as the error detail.

func (*Error) Error

func (e *Error) Error() string