view base/conditions.lisp @ 321:376357c84189

Adds condition for invalid arguments Ignore-this: acfe927d2c4491bce0cb0e603bb70392 darcs-hash:20100607105400-13bc2-298f67835349379005b43825ea47aec6121f03f3.gz
author Thomas Praetzlich <io901tp@gold.ac.uk>
date Mon, 07 Jun 2010 11:54:00 +0100
parents b16472d7823f
children
line wrap: on
line source
(cl:in-package #:amuse) 

;; Some conditions we might want to be able to signal

(define-condition undefined-action (condition)
  ;; This condition would apply to an attempt to perform a meaningless
  ;; operation on an object. This may, initially, include things that
  ;; are a pain to implement but should really be used when it's
  ;; genuinely unclear what an operation means in the given
  ;; context. In such cases, a condition handler might be the best
  ;; approach anyway.
  ((operation :initarg :operation
	      :reader undefined-action-operation)
   (datatype :initarg :datatype
	     :reader undefined-action-datatype))
  (:report (lambda (condition stream)
	     (format stream "The consequence of performing ~A on an object of type ~A is undefined."
		     (undefined-action-operation condition)
		     (undefined-action-datatype condition)))))

(define-condition insufficient-information (condition)
  ;; It should be possible to construct genuinely minimal musical
  ;; structures. When the information in these is insufficient to
  ;; answer a query, this condition should be raised.
  ((operation :initarg :operation
	      :reader insufficient-information-operation)
   (datatype :initarg :datatype
	     :reader insufficient-information-datatype))
  (:report (lambda (condition stream)
	     (format stream "The ~A object does not contain enough information to perform ~A."
		     (insufficient-information-datatype condition)
		     (insufficient-information-operation condition)))))

	   
(define-condition invalid-argument (condition)
  ;; This condition applies if a function is invoked with an invalid
  ;; argument.
  ((function :initarg :function
	     :reader invalid-argument-function)
   (argument :initarg :argument
	     :reader invalid-argument-argument))
   (:report (lambda (condition stream)
	      (format stream "The function ~A is not defined for a call with ~A"
		      (invalid-argument-function condition)
		      (invalid-argument-argument condition)))))