summaryrefslogtreecommitdiff
path: root/error.go
blob: 416d578e7356ae5074816d1e218bbb824dfb3754 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package mux

import (
	"context"
	"encoding/json"
	"io"
)

var DefaultErrorHandler func(err error) Renderer = func(err error) Renderer {
	return RendererFunc(func(ctx context.Context, w io.Writer) error {
		return json.NewEncoder(w).Encode(errorStruct{
			Message: err.Error(),
		})
	})
}

type errorStruct struct {
	Message string `json:"message"`
}