Skip to content

Commit

Permalink
ignore errors while printing error and backtrace, so we still exit pr…
Browse files Browse the repository at this point in the history
…operly
  • Loading branch information
3b committed Sep 23, 2020
1 parent 13fa20e commit 6c8395e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/utils.lisp
Expand Up @@ -4,13 +4,19 @@

(in-package :ci-utils/utils)


(defmacro with-fail-on-errors ((&key (code 123)) &body body)
"print a stack trace and then exit with CODE when BODY signals
any error"
`(handler-bind ((error (lambda (&optional e)
(format t "caught error ~s~%~a~%" e e)
(uiop:print-condition-backtrace
e :stream *standard-output*)
(format t "caught error:~%")
;; make sure we exit properly even if
;; errors or backtrace can't be printed
(ignore-errors (format t " ~a~%" e))
(ignore-errors (format t " ~s~%" e))
(ignore-errors
(uiop:print-condition-backtrace
e :stream *standard-output*))
(finish-output)
(uiop:quit ,code))))
(progn ,@body)))
Expand Down

0 comments on commit 6c8395e

Please sign in to comment.