Files
backend/api/api.go
2021-12-16 10:08:34 +01:00

18 lines
278 B
Go

package api
import (
"encoding/json"
"net/http"
)
type ApiError struct {
Message string `json:"message"`
OriginalError error
Code int
}
func (ae ApiError) Send(w http.ResponseWriter) error {
w.WriteHeader(ae.Code)
return json.NewEncoder(w).Encode(ae)
}