NAME

src/pmc/exception.pmc - Exception PMC

DESCRIPTION

This is the exception base class. An exception object has the following attributes:

message
Textual representation of the exception.
severity
The severity of the exception, (see include/parrot/exceptions.h, except_severity.pasm).
type
The type of the exception.
exit_code
The exit code of the exception. (Added temporarily, to be removed.)
handled
Whether the exception has been handled. Defaults to 0, 1 for handled, -1 for a rethrown exception.
payload
Additional data for the exception.

When an exception handler is called, the exception object is passed as as the first argument, the message as the second argument of the call. These arguments can be retrieved with the get_results opcode.

Vtable Functions

void init()
Initializes the exception with default values.
void init_pmc()
Initializes the exception with supplied values.
void mark()
Mark any active exception data as live.
INTVAL get_bool()
Return true.
STRING *get_string()
Return the exception message.
INTVAL get_integer()
Returns the id of the exception.
STRING *get_string_keyed(PMC *key)
Returns the Parrot string value for *key. The only current recognized key is "message".
INTVAL get_integer_keyed(PMC *key)
Returns the integer value for *key.
INTVAL get_integer_keyed_str(STRING *key)
Returns the integer value for *key.
PMC *get_pmc_keyed(PMC *key)
Returns the PMC value for *key.
void set_string_native(STRING *value)
Sets the message of the Exception.
void set_integer_native(INTVAL *value)
Sets the id of the Exception.
void set_number_native(FLOATVAL value)
Sets the birthtime of the exception.
void set_string_keyed(PMC *key, STRING *value)
Sets the Parrot string value for *key.
void set_integer_keyed(PMC *key, INTVAL value)
Sets the integer value for *key.
void set_integer_keyed_str(STRING *key, INTVAL value)
Sets the integer value for *key.
void set_pmc_keyed(PMC *key, PMC *value)
Sets the PMC value for *key.
void set_pointer(void *context)
Store a context for the handler iterator.
void *get_pointer()
Retrieve a context stored for the handler iterator.
INTVAL is_equal(PMC *value)
Compare the passed in Exception with SELF. Returns true if SELF and value are the same type, and have the same values for type, severity, and exit_code.
get_attr_str
Retrieve an attribute value for the exception object.
set_attr_str
Set an attribute value for the exception object.
PMC *share_ro()
Set this PMC as shared.
PMC *annotations
Gets any bytecode annotations in force at the point where the exception was thrown. If the optional name of an annotation is specified, gets just that annotation. If not, returns a Hash of all of them.
PMC *backtrace
Gets a representation of the backtrace at the point that this exception was thrown. Returns an array of hashes. Each array element represents a caller in the backtrace, the most recent caller first. The hash has two keys: sub, which holds the PMC representing the sub, and annotations which is a hash of the annotations at the point where the exception was thrown for the current sub, or for the point of the call a level deeper for the rest.

Auxliary functions

static AttrEnum getAttrEnum(PARROT_INTERP, const STRING *name)
Gets an enumerated value corresponding to the attribute with that name.