summaryrefslogtreecommitdiff
path: root/pkg/helpers/error.go
blob: 006759dcb06397eddb1101ed7f47aeaa2a143dc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package helpers

import (
	"fmt"
	"net/http"
)

func ErrorResponse(w http.ResponseWriter, status int, err error) {
	type errorResponse struct {
		Msg    string `json:"msg"`
		Status int    `json:"status"`
	}
	_ = Encode(w, status, &errorResponse{
		Msg:    fmt.Sprintf("%+v", err),
		Status: status,
	})
}