chickadee » srfi-18 » raise

raise objprocedure

Calls the current exception handler with obj as the single argument. obj may be any Scheme object.

    (define (f n)
      (if (< n 0) (raise "negative arg") (sqrt n))))
 
    (define (g)
      (call-with-current-continuation
        (lambda (return)
          (with-exception-handler
            (lambda (exc)
              (return
                (if (string? exc)
                    (string-append "error: " exc)
                    "unknown error")))
            (lambda ()
              (write (f 4.))
              (write (f -1.))
              (write (f 9.)))))))
 
    (g)  ==>  ''writes'' 2. ''and returns'' "error: negative arg"