Mailing List Archive

Re: svn commit: r168603 - /perl/modperl/docs/trunk/src/docs/2.0/api/APR/Status.pod
randyk@apache.org wrote:
> Author: randyk
> Date: Fri May 6 07:11:18 2005
> New Revision: 168603
>
> URL: http://svn.apache.org/viewcvs?rev=168603&view=rev
> Log:
> add documentation for APR::Status::is_EACCES and APR::Status::is_ENOENT.
[...]
> +An example of using C<is_EACCES> is when reading the contents of a
> +file where access may be forbidden:
> +
> + eval { $obj->slurp_filename(0) };
> + if ($@) {
> + if (ref $@ eq 'APR::Error') {
> + return Apache2::Const::FORBIDDEN if APR::Status::is_EACCES($@);
> + }
> + else {
> + return Apache2::Const::SERVER_ERROR;
> + }
> + }

there is a flow in your example, Randy: what if APR::Status::is_EACCES is
not true? Nothing handles that case -- it silently falls through.

Also I think it's always the bests to re-throw the error if you don't
handle it, so it could be:

eval { $obj->slurp_filename(0) };
if ($@) {
return Apache2::Const::FORBIDDEN
if ref $@ eq 'APR::Error' && APR::Status::is_EACCES($@);
die @; #re-throw
}

but at least it has to be:

> + if ($@) {
> + if (ref $@ eq 'APR::Error' && APR::Status::is_EACCES($@)) {
> + return Apache2::Const::FORBIDDEN;
> + }
> + else {
> + return Apache2::Const::SERVER_ERROR;
> + }
> + }

Please choose whatever you prefer.

and the same here (flowed example):

> +An example of using C<is_ENOENT> is when reading the contents of a
> +file which may not exist:
> +
> + eval { $obj->slurp_filename(0) };
> + if ($@) {
> + if (ref $@ eq 'APR::Error') {
> + return Apache2::Const::NOT_FOUND if APR::Status::is_ENOENT($@);
> + }
> + else {
> + return Apache2::Const::SERVER_ERROR;
> + }
> + }

Thanks Randy.

--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-dev-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-dev-help@perl.apache.org
Re: svn commit: r168603 - /perl/modperl/docs/trunk/src/docs/2.0/api/APR/Status.pod [ In reply to ]
Stas Bekman wrote:
> randyk@apache.org wrote:
>
>> Author: randyk
>> Date: Fri May 6 07:11:18 2005
>> New Revision: 168603
>>
>> URL: http://svn.apache.org/viewcvs?rev=168603&view=rev
>> Log:
>> add documentation for APR::Status::is_EACCES and APR::Status::is_ENOENT.

And there are more places that need to be adjusted to use the new API,
e.g.: the Apache2::RequestUtil manpage goes:

----------------------
Possible error codes could be:
C<L<APR::Const::EACCES|docs::2.0::api::APR::Const/C_APR__EACCES_>>
(permission problems),
C<L<APR::Const::ENOENT|docs::2.0::api::APR::Const/C_APR__ENOENT_>> (file not
found) and others.
----------------------

Probably others too. Try to grep for the above two constants?

Thanks.

--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-dev-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-dev-help@perl.apache.org