Manager: more graceful errors when receiving task update of unknown task
Return a 404 Not Found when the task can't be found, and a 500 on other errors.
This commit is contained in:
parent
1176d85496
commit
6bdc198301
@ -171,7 +171,10 @@ func (f *Flamenco) TaskUpdate(e echo.Context, taskID string) error {
|
||||
dbTask, err := f.persist.FetchTask(ctx, taskID)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).Msg("cannot fetch task")
|
||||
return sendAPIError(e, http.StatusNotFound, "task %+v not found", taskID)
|
||||
if errors.Is(err, persistence.ErrTaskNotFound) {
|
||||
return sendAPIError(e, http.StatusNotFound, "task %+v not found", taskID)
|
||||
}
|
||||
return sendAPIError(e, http.StatusInternalServerError, "error fetching task")
|
||||
}
|
||||
if dbTask == nil {
|
||||
panic("task could not be fetched, but database gave no error either")
|
||||
|
Loading…
x
Reference in New Issue
Block a user