signaller/errors.go

27 lines
462 B
Go
Raw Normal View History

2019-07-18 14:10:43 +00:00
package main
import (
"net/http"
2019-07-18 14:21:54 +00:00
"github.com/nxshock/signaller/matrix"
2019-07-18 14:10:43 +00:00
)
func errorResponse(w http.ResponseWriter, code matrix.ApiError, httpCode int, message string) {
w.Header().Set("Content-Type", "application/json")
if message != "" {
code.Message = message
}
w.WriteHeader(httpCode)
w.Write(code.JSON())
}
func NewError(code matrix.ApiError, message string) *matrix.ApiError {
if message != "" {
code.Message = message
}
return &code
}