Merge pull request #179 from sgotti/runservice_logshandler_improve_errors
runservice: improve errors in logsHandler
This commit is contained in:
commit
32a08ec5c8
|
@ -195,9 +195,9 @@ func (h *LogsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if sendError {
|
if sendError {
|
||||||
switch {
|
switch {
|
||||||
case util.IsNotExist(err):
|
case util.IsNotExist(err):
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
httpError(w, util.NewErrNotExist(errors.Errorf("log doesn't exist: %w", err)))
|
||||||
default:
|
default:
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
httpError(w, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,15 +241,18 @@ func (h *LogsHandler) readTaskLogs(ctx context.Context, runID, taskID string, se
|
||||||
|
|
||||||
et, err := store.GetExecutorTask(ctx, h.e, task.ID)
|
et, err := store.GetExecutorTask(ctx, h.e, task.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == etcd.ErrKeyNotFound {
|
||||||
|
return util.NewErrNotExist(errors.Errorf("executor task with id %q doesn't exist", task.ID)), true
|
||||||
|
}
|
||||||
return err, true
|
return err, true
|
||||||
}
|
}
|
||||||
executor, err := store.GetExecutor(ctx, h.e, et.Spec.ExecutorID)
|
executor, err := store.GetExecutor(ctx, h.e, et.Spec.ExecutorID)
|
||||||
if err != nil && err != etcd.ErrKeyNotFound {
|
if err != nil {
|
||||||
return err, true
|
if err == etcd.ErrKeyNotFound {
|
||||||
}
|
|
||||||
if executor == nil {
|
|
||||||
return util.NewErrNotExist(errors.Errorf("executor with id %q doesn't exist", et.Spec.ExecutorID)), true
|
return util.NewErrNotExist(errors.Errorf("executor with id %q doesn't exist", et.Spec.ExecutorID)), true
|
||||||
}
|
}
|
||||||
|
return err, true
|
||||||
|
}
|
||||||
|
|
||||||
var url string
|
var url string
|
||||||
if setup {
|
if setup {
|
||||||
|
|
Loading…
Reference in New Issue