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,8 +171,11 @@ func (f *Flamenco) TaskUpdate(e echo.Context, taskID string) error {
|
|||||||
dbTask, err := f.persist.FetchTask(ctx, taskID)
|
dbTask, err := f.persist.FetchTask(ctx, taskID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn().Err(err).Msg("cannot fetch task")
|
logger.Warn().Err(err).Msg("cannot fetch task")
|
||||||
|
if errors.Is(err, persistence.ErrTaskNotFound) {
|
||||||
return sendAPIError(e, http.StatusNotFound, "task %+v not found", taskID)
|
return sendAPIError(e, http.StatusNotFound, "task %+v not found", taskID)
|
||||||
}
|
}
|
||||||
|
return sendAPIError(e, http.StatusInternalServerError, "error fetching task")
|
||||||
|
}
|
||||||
if dbTask == nil {
|
if dbTask == nil {
|
||||||
panic("task could not be fetched, but database gave no error either")
|
panic("task could not be fetched, but database gave no error either")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user