Skip to content

Commit

Permalink
Added an INVARIANT-ERROR condition as a superclass to the specific *-…
Browse files Browse the repository at this point in the history
…INVARIANT-ERROR types.
  • Loading branch information
sellout committed Apr 13, 2011
1 parent c43befe commit f15d1ed
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dbc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@
(:export "DBC" "DEFCLASS" "MAKE-INSTANCE"
"CONTRACT-VIOLATION-ERROR"
"PRECONDITION-ERROR" "POSTCONDITION-ERROR"
"BEFORE-INVARIANT-ERROR" "AFTER-INVARIANT-ERROR"
"CREATION-INVARIANT-ERROR"))
"INVARIANT-ERROR" "CREATION-INVARIANT-ERROR"
"BEFORE-INVARIANT-ERROR" "AFTER-INVARIANT-ERROR"))

(in-package "DBC")

Expand Down Expand Up @@ -191,19 +191,22 @@
(description condition))
(format stream "Postcondition violation.")))))

(define-condition before-invariant-error (contract-violation-error)
(define-condition invariant-error (contract-violation-error)
())

(define-condition before-invariant-error (invariant-error)
()
(:report (lambda (condition stream)
(format stream "Invariant violation before method call:~% ~A."
(description condition)))))

(define-condition after-invariant-error (contract-violation-error)
(define-condition after-invariant-error (invariant-error)
()
(:report (lambda (condition stream)
(format stream "Invariant violation after method call:~% ~A."
(description condition)))))

(define-condition creation-invariant-error (contract-violation-error)
(define-condition creation-invariant-error (invariant-error)
()
(:report (lambda (condition stream)
(format stream "Invariant violation after class creation:~% ~A."
Expand Down

0 comments on commit f15d1ed

Please sign in to comment.