Skip to content

Commit

Permalink
Better error handling options in src/report/catalog.lisp
Browse files Browse the repository at this point in the history
* src/report/catalog.lisp (header): updated copyright
  (call-with-output-to-catalog-file): try to delete output file in
  case of abnormal exit
  (report sequence catalog pathname): establish `continue' restarts
  around processing of sequence elements
  (report distribution catalog pathname): use the `report' method for
  processing sequences
  • Loading branch information
scymtym committed Mar 11, 2019
1 parent 6515082 commit c920531
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/report/catalog.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;;; catalog.lisp --- Write XML catalog describing recipes.
;;;;
;;;; Copyright (C) 2015, 2016, 2017, 2018 Jan Moringen
;;;; Copyright (C) 2015, 2016, 2017, 2018, 2019 Jan Moringen
;;;;
;;;; Author: Jan Moringen <[email protected]>

Expand All @@ -23,12 +23,14 @@

(defun call-with-output-to-catalog-file (thunk directory name)
(ensure-directories-exist directory)
(with-output-to-file (stream (make-pathname :name name
:type "xml"
:defaults directory)
#+sbcl :external-format #+sbcl :utf-8
:if-exists :supersede)
(funcall thunk stream)))
(let ((filename (make-pathname :name name
:type "xml"
:defaults directory)))
(unwind-protect-case ()
(with-output-to-file (stream filename #+sbcl :external-format #+sbcl :utf-8
:if-exists :supersede)
(funcall thunk stream))
(:abort (ignore-errors (delete-file filename))))))

(defmacro with-output-to-catalog-file ((stream directory name) &body body)
`(call-with-output-to-catalog-file
Expand Down Expand Up @@ -273,7 +275,10 @@
(call-next-method)))

(defmethod report ((object sequence) (style catalog) (target pathname))
(map nil (rcurry #'report style target) object))
(map nil (lambda (element)
(with-simple-restart (continue "~@<Skip ~A~@:>" element)
(report element style target)))
object))

(defmethod report ((object jenkins.model.project::distribution)
(style catalog)
Expand All @@ -283,7 +288,7 @@
(report object style stream)))

(let ((project-directory (merge-pathnames #P"project/" target)))
(map nil (rcurry #'report style project-directory) (versions object))))
(report (versions object) style project-directory)))

(defmethod report ((object jenkins.model.project::distribution)
(style catalog)
Expand Down

0 comments on commit c920531

Please sign in to comment.