As a casual VMS user, I've always liked the way that VMS coded its error 
messages.  Perhaps a similar technique could be adopted for perl.

Each message has 4 parts:
        Facility:
                This is the thing that is reporting the error
        Severity:
                This is a severity ranking (I=informational, W=warning, 
                        E=error, F=fatal)
        Message-Code:
                This is a single word abbreviation of the 'gist' of the message
        Text Message:
                This is a human readable message giving more details.

For example, an message which may occur when using VMS may be:

%APPEND-I-CREATED, TEST.OUT;1 created.

This is an informational message from append informing us a file was created.

A VMS-like perl message may look like:

%EVAL-E-SYNTAX, syntax error at (eval 1) line 2, at EOF

Since the facility, severity, and message code are clearly separate parts of
the message, they can easily be tested with a regex:
        if($@=~m/-E-/) {
                # an error of some sort has occurred
        }


Maybe it doesn't need all the shouting, and maybe the format could be 
rearranged to make it friendlier, but it should be pretty extensible so
anything can "throw" its own error messages and still be easily caught
by regexes.  It should also allow for easy localization.  

Brian Wheeler
[EMAIL PROTECTED]

Reply via email to