An error object
represents describes how an error, warning or message with specified error-id
is handled. When an error is detected PCE will invoke object->error
on the associated object, which is normally the receiver of the
currently executing method.
An error object
defines a error<-feedback
which determines whether the error is printed in a format suitable for
the PCE programmer in the
host-language
window, raises a host-labnguage exception or is reported in a format
suitable for the application user using the general object->report
mechanism.
An error object
defines a error<-kind
that determines the nature and how serious the error is considered.
The PCE online manual has an entry Errors in the Browsers menu that allows the user to examine the available (reusable) error objects.
<-kind).
Its values are:
->report
to report the error. See also
visual->report.
-language,
and the host-language
indicates it wants to handle the error itself, the error is recorded in
the hosts goal-frame and the object->error
succeeds with failure. When control is returned to the
host-language,
the host-language
should raise and error (For example, as throw/1
in Prolog):
?- catch(send(@pce, hello), E, true).
E = error(pce(@290191/error,
[@pce/pce, (->), hello]),
send(@pce/pce, hello))
->display.
See
string->format
for a description of the format arguments. The first argument formatted
is always the generator of the error (the object receiving object->error).
The remaining arguments are the context arguments from object->error.<-convert
and error<-lookup.serious the error is. The error categories
are related to the report categories defined by object->report
(see visual ->report'), except for fatal and ignored`.
The values are:
<-feedback
equals report Invoke object->report
using error<-kind, error<-format
and the arguments passed. This message is sent to the object that
generated the error using object->error.
<-feedback
equals print Use’@pce error->format’to
print the message. If error<-kind
is
error, start the PCE tracer.
<-id, error<-format, error<-kind
and error<-feedback.
The default kind is warning and the default feedback
is report. The
error object is locked
against the garbage collector and a mapping from its error<-id
is added to the @errors
database.
The following provides a (schematic example).
:- new(_, error(key_clash,
'%N: Key %s is already in use')).
:- pce_begin_class(database, hash_table).
add(DB, Record:record) :->
"Add record to the database"::
get(Record, key, Key),
( get(DB, member, Key, _)
-> send(DB, error, key_clash, Key),
fail
; send(DB, append, Key, Record)
).
:- pce_end_class.
See also object->report.
-id
into an error object.
It uses the hash_table
@errors for
this purpose.<-lookup
in the @errors
database to ensure the uniqueness of the error identifiers.