Skip to main content

simple-condition

simple-condition Condition Type

Class Precedence List:

simple-condition, condition, t

Description:

The type simple-condition represents conditions that are signaled by signal whenever a format control is supplied as the function’s first argument. The format control and format arguments are initialized with the initialization arguments named :format-control and :format-arguments to make-condition, and are accessed by the functions simple-condition-format-control and simple-condition-format-arguments. If format arguments are not supplied to make-condition, nil is used as a default.

See Also:

simple-condition-format-control, simple-condition-format-arguments

simple-condition-format-control, simple condition-format-arguments Function

Syntax:

simple-condition-format-control condition → format-control

simple-condition-format-arguments condition → format-arguments

Arguments and Values:

condition—a condition of type simple-condition.

format-control—a format control.

format-arguments—a list.

Description:

simple-condition-format-control returns the format control needed to process the condition’s format arguments.

simple-condition-format-arguments returns a list of format arguments needed to process the condition’s format control.

Examples:

(setq foo (make-condition ’simple-condition 
:format-control "Hi ~S"
:format-arguments(ho)))
→ #<SIMPLE-CONDITION 26223553>
(apply #'format nil (simple-condition-format-control foo)
(simple-condition-format-arguments foo))
"Hi HO"

See Also:

simple-condition, Section 9.1 (Condition System Concepts)

Expanded Reference: simple-condition

The simple-condition Type

simple-condition is a condition type that provides a format control string and format arguments for reporting. It is the default type used by signal when a string is passed.

(let ((c (make-condition 'simple-condition
:format-control "Event ~A occurred at ~A"
:format-arguments '("X" "12:00"))))
(format nil "~A" c))

=> "Event X occurred at 12:00"

Accessing Format Control and Arguments

(let ((c (make-condition 'simple-condition
:format-control "~D items"
:format-arguments '(5))))
(values (simple-condition-format-control c)
(simple-condition-format-arguments c)))

=> "~D items"

simple-condition Is a Mixin

simple-condition is often combined with other types. The standard defines simple-error, simple-warning, and simple-type-error.

(subtypep 'simple-error 'simple-condition)

=> T
=> T
(subtypep 'simple-warning 'simple-condition)

=> T
=> T

Created Implicitly by signal

When signal receives a string, it creates a simple-condition.

(handler-case
(signal "something happened")
(simple-condition (c)
(simple-condition-format-control c)))

=> "something happened"