webrender

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorToSensibleString added in v0.7.0

func ErrorToSensibleString(err error) string

ErrorToSensibleString handles SQL error more sensible (When I get around to it) I don't want it to say "error": "Error 1062: Duplicate entry '\\x12\\xF6\\x8B\\xF6b\\xBCF\\x90\\xBC\\xED\\xA0\\xACa\\x066\\x92' for key 'PRIMARY'"

func NewErrBadRequest

func NewErrBadRequest(err error) render.Renderer

NewErrBadRequest creates a new ErrBadRequest

func NewErrCreate

func NewErrCreate(err error) render.Renderer

NewErrCreate creates a new ErrCreate

func NewErrCustomRender added in v0.5.6

func NewErrCustomRender(err error) render.Renderer

NewErrCustomRender creates a new ErrCustomRender This can be use by custom renderer for the user of this library.

func NewErrDBError

func NewErrDBError(err error) render.Renderer

NewErrDBError creates a new ErrDBError

func NewErrDelete

func NewErrDelete(err error) render.Renderer

NewErrDelete creates a new ErrDelete

func NewErrDuplicatedRecord added in v0.9.26

func NewErrDuplicatedRecord(err error) render.Renderer

func NewErrGenJSON

func NewErrGenJSON(err error) render.Renderer

NewErrGenJSON creates a new ErrGenJSON

func NewErrInternalServerError

func NewErrInternalServerError(err error) render.Renderer

NewErrInternalServerError

func NewErrNotFound

func NewErrNotFound(err error) render.Renderer

NewErrNotFound creates a new ErrNotFound

func NewErrParsingJSON

func NewErrParsingJSON(err error) render.Renderer

NewErrParsingJSON creates a new ErrParsingJSON

func NewErrPatch

func NewErrPatch(err error) render.Renderer

NewErrPatch creates a new ErrPatch

func NewErrPermissionDeniedForAPIEndpoint

func NewErrPermissionDeniedForAPIEndpoint(err error) render.Renderer

NewErrPermissionDeniedForAPIEndpoint creates a new ErrClientNotAuthorized

func NewErrQueryParameter

func NewErrQueryParameter(err error) render.Renderer

NewErrQueryParameter creates a new ErrQueryParameter

func NewErrReadingBody

func NewErrReadingBody(err error) render.Renderer

NewErrReadingBody creates a new ErrReadingBody

func NewErrURLParameter

func NewErrURLParameter(err error) render.Renderer

NewErrURLParameter creates a new ErrURLParameter

func NewErrUpdate

func NewErrUpdate(err error) render.Renderer

NewErrUpdate creates a new ErrUpdate

func NewErrValidation

func NewErrValidation(err error) render.Renderer

NewErrValidation presents validation errors This message is different

Types

type ErrBadRequest

type ErrBadRequest struct {
	ErrResponse
}

ErrBadRequest is on all type of errors

type ErrCreate

type ErrCreate struct {
	ErrResponse
}

ErrCreate on create (not specific yet)

type ErrCustomRender added in v0.5.6

type ErrCustomRender struct {
	ErrResponse
}

ErrCustomRender some problem with output custom rendering

type ErrDBError

type ErrDBError struct {
	ErrResponse
}

ErrDBError some problem operating with DB (maybe transaction)

type ErrDelete

type ErrDelete struct {
	ErrResponse
}

ErrDelete some problem deleting resource (not specific yet)

type ErrDuplicatedRecordRender added in v0.9.26

type ErrDuplicatedRecordRender struct {
	ErrResponse
}

ErrCustomRender some problem with output custom rendering

type ErrGenJSON

type ErrGenJSON struct {
	ErrResponse
}

ErrGenJSON is error parsing JSON and creating structs

type ErrInternalServerError

type ErrInternalServerError struct {
	ErrResponse
}

ErrInternalServerError

type ErrNotFound

type ErrNotFound struct {
	ErrResponse
}

ErrNotFound resource cannot be found (record doesn't exist)

type ErrParsingJSON

type ErrParsingJSON struct {
	ErrResponse
}

ErrParsingJSON is error parsing JSON and creating structs

type ErrPatch

type ErrPatch struct {
	ErrResponse
}

ErrPatch some problem patching resource (not specific yet) This is not even called right now because not implemented

type ErrPermissionDeniedForAPIEndpoint

type ErrPermissionDeniedForAPIEndpoint struct {
	ErrResponse
}

ErrPermissionDeniedForAPIEndpoint is permission denied for this endpoint

type ErrQueryParameter

type ErrQueryParameter struct {
	ErrResponse
}

ErrQueryParameter is an error on the URL parameter

type ErrReadingBody

type ErrReadingBody struct {
	ErrResponse
}

ErrReadingBody reading HTTP body

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"msg,omitempty"`      // user-level status message
	Code       int64  `json:"code,omitempty"`     // application-specific error code
	ErrorText  string `json:"error,omitempty"`    // application-level error message, for debugging
	MoreInfo   string `json:"moreInfo,omitempty"` // URL link
}
Maybe take into consideration my original design
{
  "error": "101",
  "developerMessage": "給開發者看的 message",
  "userMessage": "給使用者看的簡易 message",
  "moreInfo": "https://xyz.com/doc/errors/101"
}

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

Render is to satisfy the render.Render interface

type ErrURLParameter

type ErrURLParameter struct {
	ErrResponse
}

ErrURLParameter is an error on the URL parameter

type ErrUpdate

type ErrUpdate struct {
	ErrResponse
}

ErrUpdate some problem updating resource (not specific yet)

type GuardRetVal added in v0.8.0

type GuardRetVal struct {
	// ToPass is false if it is to guard against entry
	ToPass bool

	// CustomRenderer renderers controls HTTP status and return value instead of permission denied, if given.
	// If not set, permission denied by default
	Renderer render.Renderer
}

GuardRetVal is the return value for guard

type RetError added in v0.9.0

type RetError struct {
	// Error to return error, should always be set, even when having custom renderer
	// This is so that if we call datamapper or hookpoint, when we aren't using it in the
	// HTTP context, we can still handle error properly
	Error error
	// CustomRenderer if customize HTTP status
	Renderer render.Renderer
}

RetError is the hookpoint return structure

func NewRetValErrorWithMsg added in v0.9.1

func NewRetValErrorWithMsg(msg string) *RetError

func NewRetValWithError added in v0.8.1

func NewRetValWithError(err error) *RetError

func NewRetValWithRendererError added in v0.8.1

func NewRetValWithRendererError(err error, renderer render.Renderer) *RetError

Jump to

Keyboard shortcuts

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