Skip to content
This repository has been archived by the owner on Apr 11, 2020. It is now read-only.

Latest commit

 

History

History
35 lines (24 loc) · 763 Bytes

README.md

File metadata and controls

35 lines (24 loc) · 763 Bytes

elton-error-handler

The middleware has been archived, please use the middleware of elton.

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)
	})
}