cell-error-name
cell-error-name Function
Syntax:
cell-error-name condition → name
Arguments and Values:
condition—a condition of type cell-error.
name—an object.
Description:
Returns the name of the offending cell involved in the situation represented by condition.
The nature of the result depends on the specific type of condition. For example, if the condition is of type unbound-variable, the result is the name of the unbound variable which was being accessed, if the condition is of type undefined-function, this is the name of the undefined function which was being accessed, and if the condition is of type unbound-slot, this is the name of the slot which was being accessed.
See Also:
cell-error, unbound-slot, unbound-variable, undefined-function, Section 9.1 (Condition System Concepts)
Expanded Reference: cell-error-name
Retrieving the Name from a Cell Error
cell-error-name returns the name of the cell (variable, function, slot) that caused the error.
(handler-case
(symbol-value 'some-unbound-var-xyz)
(unbound-variable (c)
(cell-error-name c)))
=> SOME-UNBOUND-VAR-XYZ
With Undefined Functions
(handler-case
(fdefinition 'no-such-function-xyz)
(undefined-function (c)
(cell-error-name c)))
=> NO-SUCH-FUNCTION-XYZ
Using cell-error-name in a Handler
A practical pattern: reporting which name caused the error.
(handler-case
(progn
(makunbound 'my-temp-var)
(symbol-value 'my-temp-var))
(cell-error (c)
(format nil "The cell ~S is not accessible" (cell-error-name c))))
=> "The cell MY-TEMP-VAR is not accessible"