simple-signal.scm 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ; Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. ;;;; Signalling conditions
  3. ; I don't like the term "signal," but that's the one Gnu Emacs Lisp,
  4. ; Common Lisp, and Dylan use, so it's probably best to stick with it.
  5. (define make-condition cons)
  6. (define (signal type . stuff)
  7. (signal-condition (make-condition type stuff)))
  8. ; Error
  9. (define (error message . irritants)
  10. (apply signal 'error message irritants))
  11. ; Warn
  12. (define (warn message . irritants)
  13. (signal-condition (make-condition 'warning (cons message irritants))))
  14. ; Note
  15. (define (note message . irritants)
  16. (signal-condition (make-condition 'note (cons message irritants))))
  17. ; Syntax errors
  18. (define (syntax-error message . rest) ; Must return a valid expression.
  19. (signal-condition (make-condition 'syntax-error (cons message rest)))
  20. ''syntax-error)
  21. ; "Call error" - this means that the condition's "stuff" (cdr) is of
  22. ; the form (message procedure . args), and should be displayed appropriately.
  23. ; Proceeding from such an error should return the value that the call
  24. ; to the procedure on the args should have returned.
  25. (define (call-error message proc . args)
  26. (signal-condition (make-condition 'call-error
  27. (cons message (cons proc args)))))