Skip to content

Commit

Permalink
🐛 propagate errors for /tasks.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Jul 12, 2024
1 parent 0e52e70 commit 05ab55e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func (h TaskHandler) List(ctx *gin.Context) {
db := h.DB(ctx)
db = db.Model(&model.Task{})
db = db.Joins("Application")
db = db.Joins("Report")
db = sort.Sorted(db)
db = filter.Where(db)
var m model.Task
Expand Down Expand Up @@ -208,6 +209,8 @@ func (h TaskHandler) List(ctx *gin.Context) {
m := &list[i]
r := Task{}
r.With(m)
r.Activity = make([]string, 0)
r.Attached = make([]Attachment, 0)
resources = append(resources, r)
}

Expand Down Expand Up @@ -496,6 +499,7 @@ func (h TaskHandler) CreateReport(ctx *gin.Context) {
report := &TaskReport{}
err := h.Bind(ctx, report)
if err != nil {
_ = ctx.Error(err)
return
}
report.TaskID = id
Expand Down
3 changes: 2 additions & 1 deletion hack/add/task-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ curl -X POST ${host}/tasks/${id}/report -d \
"status": "Running",
"total": 10,
"completed": 0,
"activity": "addon started."
"activity": ["addon started."],
"errors": [{"severity":"Error","description":"This failed."}]
}' | jq -M .

0 comments on commit 05ab55e

Please sign in to comment.