fix(server,api): return 'not found' errors
This commit is contained in:
parent
3d01cf0f93
commit
51e1dc3b2d
@ -58,6 +58,12 @@ func (s *Server) updateSpec(w http.ResponseWriter, r *http.Request) {
|
|||||||
updateSpecReq.SpecData(),
|
updateSpecReq.SpecData(),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, datastore.ErrNotFound) {
|
||||||
|
api.ErrorResponse(w, http.StatusNotFound, ErrCodeNotFound, nil)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if errors.Is(err, datastore.ErrUnexpectedRevision) {
|
if errors.Is(err, datastore.ErrUnexpectedRevision) {
|
||||||
api.ErrorResponse(w, http.StatusConflict, ErrCodeUnexpectedRevision, nil)
|
api.ErrorResponse(w, http.StatusConflict, ErrCodeUnexpectedRevision, nil)
|
||||||
|
|
||||||
@ -87,6 +93,12 @@ func (s *Server) getAgentSpecs(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
specs, err := s.agentRepo.GetSpecs(ctx, agentID)
|
specs, err := s.agentRepo.GetSpecs(ctx, agentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, datastore.ErrNotFound) {
|
||||||
|
api.ErrorResponse(w, http.StatusNotFound, ErrCodeNotFound, nil)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
logger.Error(ctx, "could not list specs", logger.E(errors.WithStack(err)))
|
logger.Error(ctx, "could not list specs", logger.E(errors.WithStack(err)))
|
||||||
api.ErrorResponse(w, http.StatusInternalServerError, ErrCodeUnknownError, nil)
|
api.ErrorResponse(w, http.StatusInternalServerError, ErrCodeUnknownError, nil)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user