exn.ss
(module exn mzscheme

  (require-for-syntax
   (file "syntax.ss")
   )
   
  (provide
   (all-defined)
   )

  ;; syntax raise-exn : exception string
  ;;
  ;; TODO : Check at expansion-time whether exception actually extends exn.
  (define-syntax (raise-exn stx)
    (syntax-case stx ()
      [(_ exception message)
       (with-syntax
           ([make-proc (make-syntax-symbol stx 'make- (syntax exception))])
         (syntax
          (raise
           (make-proc
            (string->immutable-string message)
            (current-continuation-marks)))))]))
  
  ;; syntax raise-exn/append : exception string string ...
  ;;
  ;; TODO : Check at expansion-time whether exception actually extends exn.
  (define-syntax (raise-exn/append stx)
    (syntax-case stx ()
      [(_ exception message messages ...)
       (with-syntax
           ([make-proc (make-syntax-symbol stx 'make- (syntax exception))])
         (syntax
          (raise
           (make-proc
            (string->immutable-string (string-append message messages ...))
            (current-continuation-marks)))))]))

  ;; syntax raise-exn/format : exception string any ...
  ;;
  ;; TODO : Check at expansion-time whether exception actually extends exn.
  (define-syntax (raise-exn/format stx)
    (syntax-case stx ()
      [(_ exception template params ...)
       (with-syntax
           ([make-proc (make-syntax-symbol stx 'make- (syntax exception))])
         (syntax
          (raise
           (make-proc
            (string->immutable-string (format template params ...))
            (current-continuation-marks)))))]))

  )