Skip to content

Commit

Permalink
Update missing backend parameters code from 400 to 500
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Jan 26, 2024
1 parent 7410890 commit fc778e2
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,19 @@ func customErrorHandler(ctx context.Context, mux *runtime.ServeMux, marshaler ru

// Map specific gRPC error codes to HTTP status codes
switch st.Code() {
case codes.Unauthenticated:
w.WriteHeader(http.StatusUnauthorized) // 401
case codes.PermissionDenied:
w.WriteHeader(http.StatusForbidden) // 403
case codes.NotFound:
// Special case for missing tasks (TES Compliance Suite)
if (strings.Contains(st.Message(), "task not found")) {
w.WriteHeader(http.StatusInternalServerError) // 500
} else {
w.WriteHeader(http.StatusNotFound) // 404
}
case codes.PermissionDenied:
w.WriteHeader(http.StatusForbidden) // 403
case codes.Unauthenticated:
w.WriteHeader(http.StatusUnauthorized) // 401
default:
// Special case for missing backend parameters (TODO: send error codes from backends?)
if (strings.Contains(st.Message(), "backend parameters not supported")) {
w.WriteHeader(http.StatusBadRequest) // 400
} else {
w.WriteHeader(http.StatusInternalServerError) // 500
}
w.WriteHeader(http.StatusInternalServerError) // 500
}

// Write the error message
Expand Down

0 comments on commit fc778e2

Please sign in to comment.