weberrors

package
v0.0.0-...-cbea63e Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package weberrors aims to ease error reporting for webish service programming. The error type here implements the github.com/hailo-platform/H2O/platform/errors Errors interface If in doubt, ask author (John Dobronszki)

Index

Constants

View Source
const (
	BadRequest          = "BAD_REQUEST"
	InternalServerError = "INTERNAL_SERVER_ERROR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error implements the errors.Error() interface.

func New

func New() *Error

New returns a new *Error, without containing any errors (ie. .HasErrors() returns false on a newly created one).

func (*Error) AddContext

func (e *Error) AddContext(s ...string) errors.Error

func (*Error) Code

func (e *Error) Code() string

Code returns code from a Error struct

func (*Error) Context

func (e *Error) Context() []string

Context implements the errors.Error interface

func (*Error) Description

func (e *Error) Description() string

Description returns a web-friendly description or the actual description from the struct

func (*Error) Error

func (e *Error) Error() string

Error returns description from an Error struct

func (*Error) HasErrors

func (e *Error) HasErrors() bool

HasErrors returns true if Error contains any error.

func (*Error) HttpCode

func (e *Error) HttpCode() uint32

HttpCode returns either 400 if it is a client bad request or 500 if it is a server error This will probably be improvde in the future

func (*Error) MultiStack

func (e *Error) MultiStack() *stack.Multi

func (*Error) SetC

func (e *Error) SetC(k, v string) *Error

SetC sets key and value of the context map.

func (*Error) SetCode

func (e *Error) SetCode(c string) *Error

SetCode sets the error code. (eg. com.hailocab.service.organization.whatever)

func (*Error) SetD

func (e *Error) SetD(s string) *Error

SetD sets the error description. Note that you should not to set the error description if you are failing validation. If you set the description, you will get back an internal server error (500) instead of a client error (400).

func (*Error) Type

func (e *Error) Type() string

Type returns type from a Error struct

func (*Error) UnsetC

func (e *Error) UnsetC(k string) *Error

UnsetC unsets a field in the error context.

Jump to

Keyboard shortcuts

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