On Thu, 22 Nov 2001, Piers Cawley wrote:
> Some of these are going to be tricky to implement
> though. We're going to end up with a horrible big
> 'ExceptionFactory' being called from 'die' aren't we? I
> want to see this, I just don't want to be the one who
> gets stuck with implementing it. Code generation from
> perldiag ahoy...
wha? why?
most of the time i know exactly what kind of exception to
throw given the code i'm writing.
mkdir $foo or
IOException->throw($!);
very rarely do i have to check the actual "raw" exception
itself.
eval { ... };
if ($@) {
IOException->throw($@) if $@ =~ /^No such file or directory/;
GenericException->throw($@);
}
if your eval block isn't throwing a small number of types of
exceptions, you need to break it into smaller blocks that
each have one task to perform.
> If we have a common base class that's a lot easier of
> course, you can do $self->log_warning(...),
> $self->log_error(...), etc.
i doubt this is something i'd want to hang off an object
base class. more likely some kind of utility class for each
api.