[previous] [up] [next]     [index]
Next: Errors Up: Exceptions Previous: Exceptions

Primitive Exceptions

Whenever a primitive error occurs in MzScheme, an exception is raised. The value that is passed to the current exception handler is always an instance of the exn structure type. Every exn structure value has a message field that is a string, the primitive error message. The default exception handler recognizes exception values with the exn? predicate and passes the error message to the current error display handler (see error-display-handler in section 9.4.1.9).

Primitive errors do not create immediate instances of the exn structure type. Instead, an instance from a hierarchy of subtypes of exn is instantiated. The subtype more precisely identifies the error that occurred and may contain additional information about the error. The table below defines the type hierarchy that is used by primitive errors and matches each subtype with the primitive errors that instantiate it.

In the table, each bulleted line is a separate structure type. A type is nested under another when it is a subtype. The full name of the structure type (as used by predicates and selectors in the global environment) is built by combining the full name of the immediate supertype with ``:'' and the subtype name.

For example, applying a procedure to the wrong number of arguments raises an exception as an instance of exn:application:arity. An exception handler can test for this kind of exception using the global exn:application:arity? predicate. Given such an exception, the (incorrect) number of arguments provided is obtained from the exception with exn:application-value, while exn:application:arity-expected accesses the actual arity of the procedure.

 tex2html_wrap_inline154145     exn : not instantiated directly 
            fields:  message -- error message (type: immutable-string) 
                     continuation-marks -- value returned by current-continuation-marks immediately after the error is detected (type: mark-set) 
       tex2html_wrap_inline154145     user : raised by calling error 
       tex2html_wrap_inline154145     variable : unbound global variable at run-time 
                  fields:  id -- the unbound variable's global identifier (type: symbol) 
             tex2html_wrap_inline154145     keyword : attempt to change the binding of a global keyword 
       tex2html_wrap_inline154145     application : not instantiated directly 
                  fields:  value -- the error-specific inappropriate value (type: value) 
             tex2html_wrap_inline154145     arity : application with the wrong number of arguments 
                        fields:  expected -- the correct procedure arity as returned by arity (type: arity) 
             tex2html_wrap_inline154145     type : wrong argument type to a procedure, not including divide-by-zero 
                        fields:  expected -- name of the expected type (type: symbol) 
             tex2html_wrap_inline154145     mismatch : bad argument combination (e.g., out-of-range index for a vector) or platform-specific integer range error 
             tex2html_wrap_inline154145     divide-by-zero : divide by zero; application-value is always zero 
             tex2html_wrap_inline154145     continuation : attempt to cross a continuation boundary or apply another thread's continuation 
       tex2html_wrap_inline154145     else : fall-through in cond or case 
       tex2html_wrap_inline154145     struct : the supertype expression in a struct form returned a value that was not a structure type value 
       tex2html_wrap_inline154145     object : object-, class-, or interface-specific error 
       tex2html_wrap_inline154145     unit : unit- or unit/sig-specific error 
       tex2html_wrap_inline154145     syntax : syntax error, but not a read error 
                  fields:  expr -- illegal expression (or #f if unknown) (type: S-expression) 
       tex2html_wrap_inline154145     read : read parsing error 
                  fields:  port -- port being read (type: input-port) 
             tex2html_wrap_inline154145     eof : unexpected end-of-file 
       tex2html_wrap_inline154145     i/o : not instantiated directly 
             tex2html_wrap_inline154145     port : not instantiated directly 
                        fields:  port -- port for attempted operation (type: port) 
                   tex2html_wrap_inline154145     read : error reading from a port 
                   tex2html_wrap_inline154145     write : error writing to a port 
                   tex2html_wrap_inline154145     closed : attempt to operate on a closed port 
                   tex2html_wrap_inline154145     user : user-defined input port returned a non-character from the character-getting procedure 
             tex2html_wrap_inline154145     filesystem : illegal pathname or error manipulating a filesystem object 
                        fields:  pathname -- file or directory pathname (type: path) 
                                 detail -- 'ill-formed-path, 'already-exists, or 'wrong-version, indicating the reason for the exception (if available), or #f (type: symbol or false) 
             tex2html_wrap_inline154145     tcp : TCP errors 
       tex2html_wrap_inline154145     thread : raised by call-with-custodian 
       tex2html_wrap_inline154145     misc : low-level or MzScheme-specific error 
             tex2html_wrap_inline154145     unsupported : unsupported feature 
             tex2html_wrap_inline154145     user-break : asynchronous thread break 
                        fields:  continuation -- a continuation that resumes from the break (type: continuation) 
             tex2html_wrap_inline154145     out-of-memory : out of memory

Primitive procedures that accept a procedure argument with a particular required arity (e.g., call-with-input-file, call/cc) check the argument's arity immediately, raising exn:application:type if the arity is incorrect.


[previous] [up] [next]     [index]
Next: Errors Up: Exceptions Previous: Exceptions

PLT