errorhandler

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

README

cod-error-handler

Build Status

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

package main

import (
	"errors"

	"github.com/vicanso/cod"

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

func main() {

	d := cod.New()
	d.Use(errorhandler.NewDefault())

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

	d.ListenAndServe(":7001")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) cod.Handler

New create a error handler

func NewDefault

func NewDefault() cod.Handler

NewDefault create a default error handler

Types

type Config

type Config struct {
	Skipper      cod.Skipper
	ResponseType string
}

Config error handler config

Jump to

Keyboard shortcuts

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