See attached file. Regards, Enrique
I'm trying to capture "sender" exceptions and classify and transform them in different "recipient" exceptions (the "sender" and "recipient" nomenclature is ownmade)
The idea is that of using "sender" exceptions for libraries and general code and "recipient" exceptions for final code to be glued and used by final users.(see code comments below for more details of how much usefull is to classify between "sender" and "recipient" exceptions.) By default servlets exceptions in webware are transmited up the stack to Application.dispatchRequest that catch it and shows the traceback and the original exception. If we want the exception capture mechanism in Application to behave differently depending on the nature of the "recipient" exception or any other exception framework I could imagine we just can't and I have to make my own speciliazed Servlet that captures and process them. Then I have to inherit all others Servlet from it. My suggestion is next: - ¿ Why not write Application.py so that Exception handling will be plugable ? It has many advantages and I consider is not difficult to implement (basically Application.dispatchRequest will invoke the pluggin instead of hard-coded Application.handleExceptionInTransaction). Webware could then define a concrete Exception handling mechanism based in "good practices" and anyone will be able to plugin another if it doesn't suit its needs. For example if we have a SNMP aware system a SNMP pluggin will be able to speak with it, if we have a UNIX syslogd server a SYSLOGD-pluggin will send it the exceptions we consider, ... Someone else could define a security mechanism and send security exceptions alarms in convenient way. I think is a much more natural approach than "specialized" servlets. Exceptions will be propagated up to the pluggin by default. By allowing the Exception handling mechanism to be detached from normal application logic the code simplifies quite a lot also. Next comes a "recipient exception" implementation draft: class recipientException(Exception): """ - recipientException complements the normal ("sender"="origin"="cause") Exceptions (I/O Exceptions, math Exceptions, ...). - General purpose libraries with no defined final task are suggested to define/raise ("sender") exceptions while concrete apps going to be deployed to a production/test enviroment are suggested to capture "origin" Exception and raise "recipient" Exceptions once classified. """ def __init__(self, description, details, solution): """ __init__(self, description, details, solution) description String that describes the origen or cause of the exception details String that details it depthly solution String that provides for any hints or steps to solve the problem/Exception """ # Exception.__init__(self) self.description = description self.details = details self.solution = solution def __str__(self): return description+"\n"+details+"\n"+solution class userException(recipientException): """ Excepcion that must be procesed by the final user of the application. Ussually it will be generated when the final users commits an error (keyboard type mistake, an intend for a forbidden action, an incorrect format for a date, number,...) Final apps or Apps servers usually will present it as an screen "alert" to the final user. Example: try: # parseUserInput ... except: raise userException("invalid Date"+sDate,"","use dd/mm/yy format") """ def __init__(self, description, details, solution): recipientException.__init__(self, description, details, solution) class administratorException(recipientException): """ Excepcion that must be procesed by the system administrator of the application. Ussually it will be generated when problems with system/network arise (conection error, hard disk full, security exception, ...) Final apps or Apps servers (WebWare, Zope, ...) usually will send a formatted mail to the sysadmin. Example: try: # connectTo details = details + ... ... details = details + ... except: raise administratorException("Conection failed to ...",details, "Check your tcp/ip connection to ddbb server "+host) """ def __init__(self, description, details, solution): recipientException.__init__(self, description, details, solution) class implementationException(recipientException): """ Excepcion that must be procesed by the software developer of the application. Ussually it will be generated by "assert conditions" lines. Final apps, Apps servers (WebWare, Zope, ...) or (if the app is forced to finish) OSes (Linux, Windows, Mac,...) could ideally have a "bugzilla" system to inform the application developer. Example: try: # assert non-recursive path ... except: raise implementationException("Recursive path detected",details, "emailto:[EMAIL PROTECTED]") """ def __init__(self, description, details, solution): recipientException.__init__(self, description, details, solution) ¿ class securityException(...), ?