jsonapi-errors: github.com/AmuzaTkts/jsonapi-errors Index | Files

package errors

import "github.com/AmuzaTkts/jsonapi-errors"

Errors package implements the JSON API v1.0 format for errors. Ref: http://jsonapi.org/format/#errors

Index

Package Files

errors.go

func GetErrorClass Uses

func GetErrorClass(err int) int

GetErrorClass returns 400 or 500 depending of the error code passed. If the error code is less than 400 or greater or equal to 600 it returns 0.

type Bag Uses

type Bag struct {
    Errors []*Error `json:"errors"`
    Status int      `json:"status,string,omitempty"`
}

func NewBag Uses

func NewBag() *Bag

NewBag returns a new Bag

func NewBagWithError Uses

func NewBagWithError(status int, detail string) *Bag

NewBagWithError is a shorthand to `errors.NewBag().Add(status, detail)`

func (*Bag) Add Uses

func (b *Bag) Add(err *Error) *Error

func (*Bag) AddError Uses

func (b *Bag) AddError(status int, detail string) *Error

type Error Uses

type Error struct {
    Code   int                    `json:"code,string,omitempty"`
    Debug  map[string]interface{} `json:"debug,omitempty"`
    Detail string                 `json:"detail"`
    ID     string                 `json:"id,omitempty"`
    Links  *Link                  `json:"links,omitempty"`
    Meta   map[string]interface{} `json:"meta,omitempty"`
    Source *Source                `json:"source,omitempty"`
    Status int                    `json:"status,string"`
    Title  string                 `json:"title,omitempty"`
}

Error provides additional information about problems encountered while performing an operation.

func NewError Uses

func NewError(status int, detail string) *Error

func (*Error) AddSourceNode Uses

func (e *Error) AddSourceNode() *Source

func (*Error) Error Uses

func (e *Error) Error() string
func (e *Error) SetAboutLink(link string)

func (*Error) SetParameter Uses

func (e *Error) SetParameter(parameter string) *Error

func (*Error) SetPointer Uses

func (e *Error) SetPointer(pointer string) *Error
type Link struct {
    About string `json:"about,omitempty"`
}

Link should lead to further details about this error

type Source Uses

type Source struct {
    Pointer   string `json:"pointer,omitempty"`
    Parameter string `json:"parameter,omitempty"`
}

Source contain references to the source of the error

Package errors imports 1 packages (graph). Updated 2016-11-17. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).