Skip to content

Commit

Permalink
[scd] return proper http code for too big area search on the SCD subs…
Browse files Browse the repository at this point in the history
…criptions endpoint (#985)
  • Loading branch information
Shastick authored Jan 11, 2024
1 parent def4e34 commit 095ca48
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/scd/subscriptions_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,20 @@ func (a *Server) QuerySubscriptions(ctx context.Context, req *restapi.QuerySubsc

err = a.Store.Transact(ctx, action)
if err != nil {
return restapi.QuerySubscriptionsResponseSet{Response500: &api.InternalServerErrorBody{
ErrorMessage: *dsserr.Handle(ctx, stacktrace.Propagate(err, "Got an unexpected error"))}}

errResp := &restapi.ErrorResponse{Message: dsserr.Handle(ctx, err)}
switch stacktrace.GetCode(err) {
case dsserr.BadRequest:
return restapi.QuerySubscriptionsResponseSet{Response400: errResp}
case dsserr.PermissionDenied:
return restapi.QuerySubscriptionsResponseSet{Response403: errResp}
case dsserr.AreaTooLarge:
return restapi.QuerySubscriptionsResponseSet{Response413: errResp}
default:
return restapi.QuerySubscriptionsResponseSet{Response500: &api.InternalServerErrorBody{
ErrorMessage: *dsserr.Handle(ctx, stacktrace.Propagate(err, "Got an unexpected error"))}}

}
}

return restapi.QuerySubscriptionsResponseSet{Response200: response}
Expand Down

0 comments on commit 095ca48

Please sign in to comment.