1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
12 func ErrorWithStatus(err error, status int) error {
13 return errorWithStatus{err, status}
16 type errorWithStatus struct {
21 func (ews errorWithStatus) HTTPStatus() int {
25 type ErrorResponse struct {
26 Errors []string `json:"errors"`
29 func Error(w http.ResponseWriter, error string, code int) {
30 Errors(w, []string{error}, code)
33 func Errors(w http.ResponseWriter, errors []string, code int) {
34 w.Header().Set("Content-Type", "application/json")
35 w.Header().Set("X-Content-Type-Options", "nosniff")
37 json.NewEncoder(w).Encode(ErrorResponse{Errors: errors})