4.10. kink/EXCEPTION

Mod of exceptions.

4.10.1. type exception

An exception is a pair of a message str and a vec of traces.

An exception can also have the `next` exception in the chain. Exception chain is used for “suppressed” exceptions by CONTROL.with_finally. It is not for exception wrapping.

4.10.1.1. Exception.message

`message` returns the exception message str.

4.10.1.2. Exception.traces

`traces` returns a the exception traces. The result is a vec of traces, The traces are indexed from the root to the top.

4.10.1.3. Exception.have_next?

`have_next?` returns whether `Exception` has the next exception in the chain.

4.10.1.4. Exception.next

`next` returns the next exception in the chain.

Precondition:

• `Exception` must have the next exception in the chain.

4.10.1.5. Exception.raise

`raise` raises an exception.

At the tail of `raise`, the following sequence of abstract instructions is evaluated:

(val Exception)
(raise)

4.10.1.6. Exception.op_add(Tail)

`op_add` concatenates the chain of `Exception` and the chain of `Tail`, and returns an exception of the new chain.

Precondition:

• `Tail` must be an exception.

Postcondition:

• The resutl is an exception.

4.10.1.7. Exception.desc_iter

`desc_iter` returns an iter of lines describing the exception.

Each element of the iter is a str, which does NOT end with newline.

4.10.1.8. Exception.op_eq(Arg_exception)

`op_eq` returns whether the two exceptions are equal.

They are equal in either of the following conditions:

• Both exceptions don't have the next exception in the chain, the message strs are equal, and the vecs of traces are equal.

• Both exceptions have the next exception in the chain, the next exceptions are equal, the message strs are equal, and the vecs of traces are equal.

4.10.2. EXCEPTION.new(Message Traces)

`new` makes an exception val.

Preconditions:

• `Message` must be a str

• `Traces` must be a vec of traces

4.10.3. EXCEPTION.is?(Val)

Whether `Val` is an exception.