
On 2004-08-03 07:34:48, Edi Weitz wrote:
On Sat, 31 Jul 2004 02:10:11 +0200, Stefan Scholl <stesch@no-spoon.de> wrote:
There could be different approaches:
* Simple hash A hash with error code as key and handler as value.
+ Easy to implement + Can handle all errors (thrown by handlers _and_ when no dispatcher is found) - Not very flexible. Just checks for the code and not for any request data.
* Error dispatcher Like the normal dispatcher, but checking for the right error output handler.
+ Can handle all errors (thrown by handlers _and_ when no dispatcher is found) + Flexible. Can check the code _and_ request data. - A bit big. The same effort like handling normal requests.
* Handler outputs itself and signals that A handler wants to return a 404. It constructs the output string and signals the fact that there's no need for TBNL to build the HTML for the output.
+ Easy to implement(? clean?) + Flexible - Can't handle all errors. (No handler found? Then the code won't be executed.)
* Generic function Make a specialized method if you want to catch a certain error. E. g. (defmethod error-handler ((code (eql #.+http-not-found+)) ... + Easy to implement + Can handle all errors (thrown by handlers _and_ when no dispatcher is found) + Let CLOS to the "lookup" work + CLOS: You can add :before, :around, :after, ... methods - Not very flexible. Just checks for the code and not for any request data.
I agree that this would generally be a good idea. I'm not sure yet which of the above-mentioned alternatives I like most or if there's another one that would even be better.
Do we need all the features (and more) of Apache's ErrorDocument? <http://httpd.apache.org/docs/mod/core.html#errordocument> A function can call the redirect itself. If you don't need someting similar to the contexts (server config, virtual host, directory, .htaccess) of ErrorDocument then a hash table or generic function is enough. The contexts can be simulated with error dispatcher which checks the request, too. But how often would someone need this together with mod_lisp? If someone wants to emit different error messages for the same error code but different request data (host, uri, ...) then he could handle this himself. Regards, Stefan