Improve error reporting on background tasks

This commit is contained in:
Andrey Antukh 2022-02-15 09:22:00 +01:00 committed by Andrés Moya
parent 321b2c7c23
commit 9b78b2a432
4 changed files with 19 additions and 18 deletions

View file

@ -108,7 +108,7 @@
(and (instance? java.sql.SQLException val)
(contains? #{"08003" "08006" "08001" "08004"} (.getSQLState ^java.sql.SQLException val)))
(do
(l/error :hint "connection error, trying resume in some instants")
(l/warn :hint "connection error, trying resume in some instants")
(a/<! (a/timeout poll-interval))
(recur))
@ -121,8 +121,8 @@
(instance? Exception val)
(do
(l/error :cause val
:hint "unexpected error ocurried on polling the database (will resume in some instants)")
(l/warn :cause val
:hint "unexpected error ocurried on polling the database (will resume in some instants)")
(a/<! (a/timeout poll-ms))
(recur))
@ -251,8 +251,7 @@
[error item]
(let [data (ex-data error)]
(merge
{:id (uuid/next)
:hint (ex-message error)
{:hint (ex-message error)
:spec-problems (some->> data ::s/problems (take 10) seq vec)
:spec-value (some->> data ::s/value)
:data (some-> data (dissoc ::s/problems ::s/value ::s/spec))
@ -424,6 +423,7 @@
(run-task conn))
(catch Throwable cause
(l/error :hint "unhandled exception on scheduled task"
::l/context (get-error-context cause task)
:task-id id
:cause cause))))]
(try