Previous: Basic Methods, Up: Default Superclass

15.3 Signal Handling

The default superclass defines methods for managing error conditions. These methods all throw a signal for a particular error condition.

By implementing one of these methods for a class, you can change the behavior that occurs during one of these error cases, or even ignore the error by providing some behavior.

— Function: slot-missing object slot-name operation &optional new-value

Method invoked when an attempt to access a slot in object fails. slot-name is the name of the failed slot, operation is the type of access that was requested, and optional new-value is the value that was desired to be set.

This method is called from oref, oset, and other functions which directly reference slots in EIEIO objects.

The default method signals an error of type invalid-slot-name. See Signals.

You may override this behavior, but it is not expected to return in the current implementation.

This function takes arguments in a different order than in CLOS.

— Function: slot-unbound object class slot-name fn

Slot unbound is invoked during an attempt to reference an unbound slot. object is the instance of the object being reference. class is the class of object, and slot-name is the offending slot. This function throws the signal unbound-slot. You can overload this function and return the value to use in place of the unbound value. Argument fn is the function signaling this error. Use slot-boundp to determine if a slot is bound or not.

In clos, the argument list is (class object slot-name), but eieio can only dispatch on the first argument, so the first two are swapped.

— Function: no-applicable-method object method &rest args

Called if there are no implementations for object in method. object is the object which has no method implementation. args are the arguments that were passed to method.

Implement this for a class to block this signal. The return value becomes the return value of the original method call.

— Function: no-next-method object &rest args

Called from call-next-method when no additional methods are available. object is othe object being called on call-next-method. args are the arguments it is called by. This method signals no-next-method by default. Override this method to not throw an error, and its return value becomes the return value of call-next-method.