This section contains the bare minimum that is required to construct a
user's augmented exception and throw it. It is
the frameworker's job to set
up the exception for throwing.
The physicists module must have:
You would also include
your frameworker's custom handler.
Because the exception handler must compare the exception name and facility of different classes of augmented exceptions, these strings must be different. Otherwise the hierarchy will not work properly. (see Hierarchy Based on Name and Facility for a more specific reason). Therefore, there are static functions that can be called for any augmented exception:
//assuming 'overQuota' is your augmented exception class //that your frameworker has set up overQuota::setName("Exception Name"); overQuota::setFacility("Facility Name");Note: these two functions change only the specific class' values and not its subclasses' names or facilities. The subclasses' values should be changed separately. Also, only one of these must be different in order for the hierarchy to work.
setHandler(HandlerClassName( )) function
should be called in the same manner to designate your custom handler. Unlike
the previous two functions the subclass' handlers could change.
This is because the handler for a ZMexDerivedAug is LogViaParent( ) by default
which means that the exception will use whatever handler its parent class
To actually throw an exception, create an augmented exception object by using your frameworker's typedef (in this example 'overQuota') and passing the constructor one of your extra objects. Then, use ZMthrow to throw it. The suggested way to throw an exception is:
point extra(23, 12); //creates my extra object- a point's coordinates ZMthrow(overQuota(extra));
The logged messages will look like:
%ERLOG-i ErrorObj Name: x-coord = 23 y-coord = 12 Facility Name-I-Exception Name [#1] Mon Jul 26 10:38:38 1999 -- ZMthrow was issued at line 58 of file "basic.cc" ... Exception ignored 26-Jul-1999 10:38:38This message contains a regular (i.e. non-augmented) exception log which is shown in green. Take a look at a breakdown of a similar exception log.
-iindicates that the ErrorObj logged was of severity ELinfo.
x-coord = 23 y-coord = 12
|Exception Facility||Same as the facility of its regular(i.e. non-Augmented) exception base class|
|Exception Handler||ZMexThrowErrors( )||ZMexHandleViaParent( )|
|Exception Logger||ZMexLogAlways( )||ZMexLogViaParent( )|
|ErrorObj Name||The exception name|
|ErrorLog Properties||No Name; No Subroutine;|
overQuota(extra, "ErrorObj Name", ZMexNORMAL);
ErrorObj errobj(ELerror,"ErrorObj Name");
Note: The ErrorObj timestamp may differ from the
timestamp in the exception log if option 2 is used because ErrorObj's
gather that information when they are constructed. The Frameworker is able to
remove the ErrorObj timestamp with
a simple function call.
errobj << "\nThis message will show up in my log";
overQuota(extra, errobj, ZMexINFO);
overQuota xepshun(extra); ErrorObj& errobj = xepshun.getErrorObj(); errobj << "\nWhatever you want to add.";This ensures that the severity of the ErrorObj is the same as the severity of the augmented exception.
#include "ErrorLogger/ErrorLog.h" //... ErrorLog errlog("ErrorLog Name"); overQuota::setErrorLogger(errlog);
#include "Exceptions/ZMexLogger.h" //... overQuota::setLogger(ZMexLoggerName());Check out the list of available loggers.