leibowitz
Experimental Common Lisp object storage abstraction for Unix file systems
leibowitz/core/conditions.lisp
Download raw file: core/conditions.lisp
;;; Define conditions used by the core library (in-package :leibowitz.core) ;;; FIXME: Use me in practice! (define-condition friendly-error (error) ((msg :initarg :msg)) (:report (lambda (c s) (with-slots (msg) c (format s msg)))) (:documentation "Superclass of errors that are expected to occur, typically as a result of user error. All errors that don't inherit from this should be assumed to be the result of bugs and shown to the user in the loudest, most technically useful way possible.")) (define-condition datum-not-indexed (friendly-error) ((id :initarg :id) (lib :initarg :lib)) (:report (lambda (c s) (with-slots (id lib) c (format s "Datum with id ~S not present in ~S~%" id lib))))) (define-condition datum-already-exists (friendly-error) ((d :initarg :d)) (:report (lambda (c s) (with-slots (d) c (format s "Datum ~S already exists" d))))) (define-condition cannot-mv-or-cp-to-itself (friendly-error) ((d :initarg :d)) (:report (lambda (c s) (with-slots (d) c (format s "Cannot copy or rename ~S to itself" d))))) (define-condition no-such-datum-in-disk-or-db (friendly-error) ((id :initarg :id) (lib :initarg :lib)) (:report (lambda (c s) (with-slots (id lib) c (format s "Datum with ~S does not exist on disk or in ~S" id lib))))) (define-condition datum-is-orphaned (friendly-error) ((id :initarg :id)) (:report (lambda (c s) (with-slots (id) c (format s "Underlying file for ~S has been moved or deleted!" id))))) (define-condition no-such-tag (friendly-error) ((name :initarg :name) (lib :initarg :lib)) (:report (lambda (c s) (with-slots (name lib) c (format s "Tag with name ~S not present in ~S" name lib))))) (define-condition tag-already-exists (friendly-error) ((name :initarg :name)) (:report (lambda (c s) (with-slots (name) c (format s "Tag ~S already exists" name))))) (define-condition file-not-regular (friendly-error) ((path :initarg :path)) (:report (lambda (c s) (with-slots (path) c (format s "File ~S is not regular" path))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Unfriendly errors (define-condition no-applicable-collection (error) ((id :initarg :id)) (:report (lambda (c s) (with-slots (id) c (format s "No collection found for datum ~S" id)))))