Lines Matching full:exception

3     <title>libsm : Exception Handling</title>
10 <h1> libsm : Exception Handling </h1>
16 The exception handling package provides the facilities that
33 Instead, errors are represented by exception objects.
34 An exception object contains an exception code and an array
35 of zero or more exception arguments.
36 The exception code is a string that specifies what kind of exception
37 this is, and the arguments may be integers, strings or exception objects.
43 error handling code. Errors are reported by raising an exception.
44 When an exception is raised, we unwind the call stack
45 until we find an exception handler. If the exception is
46 not handled, then we print the exception on stderr and
60 ** Exception types
83 ** Exception objects
143 ** and/or handle an exception.
146 Block of code that may raise an exception.
148 Cleanup code that may raise an exception.
149 This clause is guaranteed to be executed even if an exception is
153 Exception handling code, triggered by an exception
161 An exception is an object which represents an exceptional condition,
166 raising an exception, rather than by returning an error code or
168 capable of raising an exception, its name ends in "_x".
169 (We do not raise an exception when a bug is detected in the
174 When you are using the libsm exception handling package,
183 by raising an exception.
185 Here is an example of how to construct an exception object
186 and raise an exception.
187 In this example, we convert a Unix system error into an exception.
201 Instead, you raise an exception.
202 This causes cleanup code in surrounding exception handlers
215 The latter code raises an exception, unwinding the call stack
217 If the exception is not handled, then the exception is printed
235 names ending in _x, then it is possible that an exception will be
243 ... some code that can raise an exception ...
250 The SM_TRY ... SM_EXCEPT ... control structure handles an exception.
252 For example, here is a simple exception handler
257 /* code that can raise an exception */
267 an exception after handling it. In the rare case that you want an
268 exception to outlive an exception handler, then you increment its
274 For example, you might want to handle an end-of-file exception
280 /* code that might raise end-of-file, or some other exception */
286 /* what to do if some other exception is raised */
292 <h2> Exception Values </h2>
304 An exception object is created by specifying an exception type
305 and a list of exception arguments.
308 The exception arguments are an array of zero or more values.
313 The number and types of exception arguments is determined by
314 the exception type.
317 An exception type is a statically initialized const object
332 The <i>class</i> is used to assign the exception type to
334 exception handler might want to discriminate.
343 recourse is to raise an exception, execute cleanup code
345 The out-of-memory exception raised by sm_malloc_x
357 <dd>This exception is being raised in order to effect a
367 Note that it is extremely dangerous to raise an exception
374 Eric's 1985 exception handling system which allowed you to
377 The <i>name</i> uniquely identifies the exception type.
385 Each code indicates the type of one of the exception arguments.
387 argument list into an exception argument vector.
392 The exception argument has type <tt>int</tt>.
395 The exception argument has type <tt>long</tt>.
398 The exception argument has type <tt>SM_EXC_T*</tt>.
400 to an exception. The pointer value is simply copied
401 into the exception argument vector.
404 The exception argument has type <tt>char*</tt>.
410 The exception argument has type <tt>char*</tt>.
422 This function prints an exception of the specified type
427 <h2> Standard Exceptions and Exception Types </h2>
429 Libsm defines one standard exception value, <tt>SmHeapOutOfMemory</tt>.
431 like a bad idea to dynamically allocate an exception object to
433 This exception has category <tt>"F:sm.heap"</tt>.
434 If you need to, you can explicitly raise this exception
438 Statically initialized exception values cannot contain any
440 a new exception object whenever you raise an exception.
441 Before you can create an exception, you need an exception type.
442 Libsm defines the following standard exception types.
457 Here's an example of raising an exception:
466 then the exception raised by the above code will be printed as
479 in application contexts where you are raising an exception
481 You know the exception won't be handled,
483 later analysis by an exception handler.
493 <h2> Custom Exception Types </h2>
497 then you need to define one or more new exception types.
500 Every new exception type needs a print function.
503 It prints the <tt>etype_printcontext</tt> string of the exception type,
505 exception argument.
506 If exception argument 3 is an int or long,
523 The fourth exception is raised if a compiled regular expression
524 is invalid: this exception has no arguments.
525 The fifth exception is raised if the package runs out of memory:
526 for this, you use the standard <tt>SmHeapOutOfMemory</tt> exception.
529 The obvious approach is to define 4 separate exception types.
579 If <tt>i==42</tt> then this exception will be printed as:
584 An exception handler can provide special handling for regular
588 ... code that might raise an exception ...
599 make sense to define a single exception type, patterned after SmEtypeOs,
600 and include the integer code as an exception argument.
603 Your package might intercept an exception E generated by a lower
608 When you do this, the new exception E' should include the original
609 exception E as an exception parameter, and the print function for
610 exception E' should print the high level description of the exception
612 then print the subexception that is stored as an exception parameter.
620 Create a new exception. Raise an exception on heap exhaustion.
621 The new exception has a reference count of 1.
624 A list of zero or more exception arguments follows the exception type;
625 these are copied into the new exception object.
635 exception will be handled, it also has no idea of which resource
636 pool, if any, should own the exception.
641 Increment the reference count of an exception.
647 Decrement the reference count of an exception.
648 If it reaches 0, free the exception object.
653 Compare the exception's category to the specified glob pattern,
659 Print the exception on the stream
665 Write the exception on the stream without a terminating newline.
670 Raise the exception. This function does not return to its caller.
686 A block of code that may raise an exception.
688 Cleanup code that may raise an exception.
690 an exception was raised by a previous clause.
693 Exception handling code, which is triggered by an exception
695 The exception value is bound to the local variable 'e'.
702 If one or more of these clauses was terminated by an exception,
703 then the first such exception is remembered, and the other exceptions
706 If no exception was raised, then we are done.
709 and the first SM_EXCEPT clause whose pattern argument matches the exception
711 If none of the SM_EXCEPT clauses matched the exception, or if there are
712 no SM_EXCEPT clauses, then the remembered exception is re-raised.
720 If you do this, you will corrupt the internal exception handling stack.
725 for freeing the exception object.