httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+gm...@sunstarsys.com>
Subject Re: status and error handling in apreq2
Date Tue, 29 Jun 2004 19:33:27 GMT
Stas Bekman <stas@stason.org> writes:

> > OK- agreed in principle.  However, if a parser fails and the user
> > traps the error, they might also need to know how more details about
> > the failure than can be supplied through $@.
> > Take this for instance:
> >   my $req = Apache::Request->new($r);
> >   my $data = eval { $req->param("foo") };
> >   if ($@) {
> >     # user still wants to know if the "foo" param is available,
> >     # because it may have been available (through param()!)
> >     # prior to the parser entering an error state.   How do we
> >     # retrieve the "foo" param now?
> >       }
> 
> give me an example why would you want to continue here at all? How do
> you know that there is no more foo params later on in the input that
> caused the error? 

In scalar context param() returns the first "foo" it finds, which may
have come from a valid query-string.  Subsequent POST data parsing might
have detected an error in the incoming request body, thus the potential
for an exception in param().

However, depending on how we actually implement the exceptions, we could
ensure the above call would still succeed in this situation.

> How do you that it wasn't just a partial foo?

No partial params ever make it into our tables, not even during uploads.
If a parser error happened during processing of a foo param, that param
will not appear in the output table.

> In any case, mp2 throws object exceptions, apreq can do the same and provide
> its own attributes and overloads. so by default $@ will be stringified
> to give a general error message, but let the user to access individual
> attrbutes of that error object. so you could set some attribute
> telling the user whether the initial quest has succeeded. 

+1.  Better still would be to provide the current req->args and req->body
tables (as exception attributes), so the user can examine them if necessary.

-- 
Joe Schaefer


Mime
View raw message