errorhandler

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: Apache-2.0 Imports: 5 Imported by: 1

README

elton-error-handler

Build Status

Error handler for elton, it convert error to json/text response(NewDefault). Suggest to use hes.Error for custom error.

package main

import (
	"errors"

	"github.com/vicanso/elton"

	errorhandler "github.com/vicanso/elton-error-handler"
)

func main() {

	e := elton.New()
	e.Use(errorhandler.NewDefault())

	e.GET("/", func(c *elton.Context) (err error) {
		err = errors.New("abcd")
		return
	})

	err := e.ListenAndServe(":3000")
	if err != nil {
		panic(err)
	})
}

Documentation

Index

Constants

View Source
const (
	// ErrCategory error cateogry of error handler
	ErrCategory = "elton-error-handler"
)

Variables

This section is empty.

Functions

func New

func New(config Config) elton.Handler

New create a error handler

func NewDefault

func NewDefault() elton.Handler

NewDefault create a default error handler

Types

type Config

type Config struct {
	Skipper      elton.Skipper
	ResponseType string
}

Config error handler config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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