Reputation: 4184
I am currently developing using the cxml-stp framework, but while parsing I do get a cxml-stp:stp-error, which is a subclass of simple-error, which is documented to be a kind of error where a format-control is supplied.
How can I print the error message? As neither API supplies any specific functions and a simple FORMAT
just results in the object being printed but not using the supplied FORMAT string.
e.g.
(SB-KERNEL:CASE-FAILURE
ETYPECASE
#<CXML-STP:STP-ERROR "text includes characters that cannot be ~
represented in XML at all: ~S"
{1007814951}>
(STRING SIMPLE-STRING))
Upvotes: 1
Views: 215
Reputation:
(defun try-handle-error (err)
(handler-case
(error err)
(serious-condition (condition)
(apply #'format
(nconc (list t)
(cons (simple-condition-format-control condition)
(simple-condition-format-arguments condition)))))))
(try-handle-error (make-condition
'simple-error
:format-control "say something ~s~&"
:format-arguments '(42)))
This would be an example. Basically, format-control and format-arguments are slot-readers declared on simple-error class. When you handle an error, you can call them on that error to get the values it received during creation.
Upvotes: 1
Reputation: 139311
Simply write the condition object without escaping:
(write condition :escape nil)
Upvotes: 3