Skip to content

Commit

Permalink
handle error off of update by id on process errand (#16)
Browse files Browse the repository at this point in the history
* handle error off of update by id on process errand

* Update errands-routes.go

Co-authored-by: Michael Moghaddam <[email protected]>

Co-authored-by: Michael Moghaddam <[email protected]>
  • Loading branch information
jbonzo and mmoghaddam385 authored Nov 3, 2021
1 parent 3c5fbcd commit 0775674
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions errands-routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ func (s *ErrandsServer) processErrand(c *gin.Context) {

procErrand = errands[0]

// We are processing this errand. This won't ever return error
updatedErrand, _ := s.UpdateErrandByID(procErrand.ID, func(errand *schemas.Errand) error {
updatedErrand, err := s.UpdateErrandByID(procErrand.ID, func(errand *schemas.Errand) error {
errand.Started = utils.GetTimestamp()
errand.Attempts++
errand.Status = schemas.StatusActive
Expand All @@ -234,6 +233,15 @@ func (s *ErrandsServer) processErrand(c *gin.Context) {
return nil
})

if err != nil {
log.WithError(err).Warn("potentially no job found")

c.JSON(http.StatusNotFound, gin.H{
"message": "No jobs",
})
return
}

s.AddNotification("processing", updatedErrand)
c.JSON(http.StatusOK, gin.H{
"status": "OK",
Expand Down

0 comments on commit 0775674

Please sign in to comment.