Add proper error reporting on debug.validare fn

This commit is contained in:
Andrey Antukh 2023-11-17 11:31:45 +01:00 committed by Andrés Moya
parent f06be2727e
commit 973214ea50
3 changed files with 41 additions and 14 deletions

View file

@ -7,6 +7,7 @@
(ns app.main.errors
"Generic error handling"
(:require
[app.common.exceptions :as ex]
[app.common.pprint :as pp]
[app.common.schema :as sm]
[app.main.data.messages :as msg]
@ -57,6 +58,22 @@
(print-explain! cause)
(print-trace! cause))))
(defn print-error!
[cause]
(cond
(map? cause)
(print-cause! (:hint cause "Unexpected Error") cause)
(ex/error? cause)
(print-cause! (ex-message cause) (ex-data cause))
:else
(let [trace (.-stack cause)]
(print-cause! (ex-message cause)
{:hint (ex-message cause)
::trace trace
::instance cause}))))
(defn on-error
"A general purpose error handler."
[error]