[#818] Tasks: don't call System/exit
This commit is contained in:
parent
87acecba52
commit
f49178786c
2 changed files with 8 additions and 5 deletions
|
|
@ -79,7 +79,8 @@
|
||||||
(defn error-handler [^Exception e opts]
|
(defn error-handler [^Exception e opts]
|
||||||
(binding [*out* *err*]
|
(binding [*out* *err*]
|
||||||
(let [d (ex-data e)
|
(let [d (ex-data e)
|
||||||
exit-code (:bb/exit-code d)
|
cause-exit (some-> e ex-cause ex-data :exit)
|
||||||
|
exit-code (or (:exit d) cause-exit)
|
||||||
sci-error? (isa? (:type d) :sci/error)
|
sci-error? (isa? (:type d) :sci/error)
|
||||||
ex-name (when sci-error?
|
ex-name (when sci-error?
|
||||||
(some-> ^Throwable (ex-cause e)
|
(some-> ^Throwable (ex-cause e)
|
||||||
|
|
@ -120,7 +121,7 @@
|
||||||
(when-not (str/blank? st) st))]
|
(when-not (str/blank? st) st))]
|
||||||
(ruler "Stack trace")
|
(ruler "Stack trace")
|
||||||
(println st)))
|
(println st)))
|
||||||
(when (:verbose? opts)
|
(when (:debug opts)
|
||||||
(ruler "Exception")
|
(ruler "Exception")
|
||||||
(print-stack-trace e))
|
(print-stack-trace e))
|
||||||
(flush)
|
(flush)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
(binding [*out* *err*]
|
(binding [*out* *err*]
|
||||||
(println (format "[bb %s]" (:name @task)) (str/join " " strs))))))
|
(println (format "[bb %s]" (:name @task)) (str/join " " strs))))))
|
||||||
|
|
||||||
(defn log-error [& strs]
|
#_(defn log-error [& strs]
|
||||||
(let [log-level @log-level]
|
(let [log-level @log-level]
|
||||||
(when (or
|
(when (or
|
||||||
;; log error also in case of info level
|
;; log error also in case of info level
|
||||||
|
|
@ -47,8 +47,10 @@
|
||||||
zero-exit?)]
|
zero-exit?)]
|
||||||
(if continue? proc
|
(if continue? proc
|
||||||
(do (when-not zero-exit?
|
(do (when-not zero-exit?
|
||||||
(log-error "Terminating with non-zero exit code:" exit-code))
|
(binding [*out* *err*]
|
||||||
(System/exit exit-code)))))))
|
(println "Received non-zero exit code in task:" (:name @task))))
|
||||||
|
(throw (ex-info (str "Error during task: " (:name @task))
|
||||||
|
{:proc proc :task task :exit exit-code}))))))))
|
||||||
|
|
||||||
(def default-opts
|
(def default-opts
|
||||||
{:in :inherit
|
{:in :inherit
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue