mirror of
https://github.com/simon987/task_tracker.git
synced 2025-04-10 05:56:42 +00:00
Error handling
This commit is contained in:
parent
e09e16e0fd
commit
fd0b421276
@ -1,7 +1,9 @@
|
||||
package storage
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
|
||||
func handleErr(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
logrus.WithError(err).Fatal("Error during database operation!")
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,9 @@ func (database Database) ReleaseTask(id int64, workerId int64, result TaskResult
|
||||
row := db.QueryRow(fmt.Sprintf(`SELECT release_task_ok(%d,%d,%d)`, workerId, id, verification))
|
||||
|
||||
err := row.Scan(&taskUpdated)
|
||||
handleErr(err)
|
||||
if err != nil {
|
||||
taskUpdated = false
|
||||
}
|
||||
} else if result == TR_FAIL {
|
||||
res, err := db.Exec(`UPDATE task SET (status, assignee, retries) =
|
||||
(CASE WHEN retries+1 >= max_retries THEN 2 ELSE 1 END, NULL, retries+1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user