You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Rodent of Unusual Size <Ke...@Golux.Com> on 2004/05/24 18:22:32 UTC

[PATCH] full[er] disclosure on module not-found

have_module() currently is rather terse when the problem with a
perl module is actually with something the module requires or uses.
here's a patch which will extract a little more info from $@ if it
can, and provide it as part of the message.  helpful for tracking
down what is *actually* at fault..

any problems with it?  it changes the output of have_module(), so i'm
not committing it without at least offering it for discussion..
-- 
#ken	P-)}

Ken Coar, Sanagendamgagwedweinini  http://Ken.Coar.Org/
Author, developer, opinionist      http://Apache-Server.Com/

"Millennium hand and shrimp!"

Re: [PATCH] full[er] disclosure on module not-found

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>I think it's OK to add any extra logging in the verbose mode though
>>(when -verbose is passed) if you find it helpful as a developer. The
>>verbose mode is for developers and for when users have problems, so any
>>extra useful info is a goodness.
> 
> 
> yeah, that's a good idea.
> 
> 
>>>nevertheless, it might be useful if you swapped the logic around, adding
>>>additional $why only if the error isn't the standard "Can't locate
>>>Bar.pm in
>>>@INC..."
>>
>>
>>Yes, I don't quite understand what's the added value of your patch, as
>>you add the extra output when it can't find the file. Where is your
>>supporting email, talks about the opposite case. You probably wanted
>>something like:
>>
>>  $why .= "$@" unless $@ =~ /^Can't locate/;
> 
> 
> ken and I talked about this over irc.  the issues he had seemed to stem from
> the fact that the error thrown from use() isn't always intuitive to non-perl
> folks.  specifically, the error message from have_module is 'couldn't find
> module' which is a bit misleading - in many cases perl can "find" the module
> just fine, but it can't be used due to missing dependencies (ken's current
> problem).
> 
> so, I'd suggest making the the have_module message a bit clearer, maybe
> something like 'module $module not available' or somesuch.
> 
> also, ken pointed out that $@ will contain "Can't locate Bar.pm in @INC" if
> you use() Foo.pm and Foo.pm use()s Bar.pm and Bar.pm is missing.  so
> 
>   $@ =~ /^Can't locate/;
> 
> should probably be something like
> 
>   $@ =~ /^Can't locate $module/;
> 
> or somesuch, so that a missing Foo.pm is not reported verbosely, but a
> missing Bar.pm is.

Understood.

> then again, if the current behavior can be maintained and $@ printed only in
> -verbose mode you don't really need a regex at all.

All, but the case when it can't find a file. In which case $@ is too big to 
print, usually it can go up to 10 lines listing tons of dirs in @INC.

There should be a clear distinction between the module is not there -- we 
don't want any errors printed out at all (that's why we use have_module() and 
not just require) and the module is there but something goes wrong, in which 
case an explanation is due.

I didn't participate in the discussion, but may be Ken should use require 
instead of have_module(), at least while developing. Dunno if that's what he 
is after.


-- 
__________________________________________________________________
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

Re: [PATCH] full[er] disclosure on module not-found

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I think it's OK to add any extra logging in the verbose mode though
> (when -verbose is passed) if you find it helpful as a developer. The
> verbose mode is for developers and for when users have problems, so any
> extra useful info is a goodness.

yeah, that's a good idea.

> 
>> nevertheless, it might be useful if you swapped the logic around, adding
>> additional $why only if the error isn't the standard "Can't locate
>> Bar.pm in
>> @INC..."
> 
> 
> Yes, I don't quite understand what's the added value of your patch, as
> you add the extra output when it can't find the file. Where is your
> supporting email, talks about the opposite case. You probably wanted
> something like:
> 
>   $why .= "$@" unless $@ =~ /^Can't locate/;

ken and I talked about this over irc.  the issues he had seemed to stem from
the fact that the error thrown from use() isn't always intuitive to non-perl
folks.  specifically, the error message from have_module is 'couldn't find
module' which is a bit misleading - in many cases perl can "find" the module
just fine, but it can't be used due to missing dependencies (ken's current
problem).

so, I'd suggest making the the have_module message a bit clearer, maybe
something like 'module $module not available' or somesuch.

also, ken pointed out that $@ will contain "Can't locate Bar.pm in @INC" if
you use() Foo.pm and Foo.pm use()s Bar.pm and Bar.pm is missing.  so

  $@ =~ /^Can't locate/;

should probably be something like

  $@ =~ /^Can't locate $module/;

or somesuch, so that a missing Foo.pm is not reported verbosely, but a
missing Bar.pm is.

then again, if the current behavior can be maintained and $@ printed only in
-verbose mode you don't really need a regex at all.

--Geoff

Re: [PATCH] full[er] disclosure on module not-found

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> Rodent of Unusual Size wrote:
> 
>>have_module() currently is rather terse when the problem with a
>>perl module is actually with something the module requires or uses.
>>here's a patch which will extract a little more info from $@ if it
>>can, and provide it as part of the message.  helpful for tracking
>>down what is *actually* at fault..
> 
> 
> well, in the _vast_ majority of cases I would expect the error message to
> read "Can't locate...".  that's the purpose of have_module after all, to
> ping if the module is there or not.
> 
> in the rare cases where the module is there but can't be loaded (such as
> modules in development) it might be useful to have additional information.
> but have_module() really isn't there as a development tool - that's what
> perl -cw is for :)

Seconded.

In addition extra verbosity in the terse mode is not helpful at all, it makes 
the output hard to read. Especially when you have lots of tests.

I think it's OK to add any extra logging in the verbose mode though (when 
-verbose is passed) if you find it helpful as a developer. The verbose mode is 
for developers and for when users have problems, so any extra useful info is a 
goodness.

> nevertheless, it might be useful if you swapped the logic around, adding
> additional $why only if the error isn't the standard "Can't locate Bar.pm in
> @INC..."

Yes, I don't quite understand what's the added value of your patch, as you add 
the extra output when it can't find the file. Where is your supporting email, 
talks about the opposite case. You probably wanted something like:

   $why .= "$@" unless $@ =~ /^Can't locate/;

no?

-- 
__________________________________________________________________
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

Re: [PATCH] full[er] disclosure on module not-found

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Rodent of Unusual Size wrote:
> have_module() currently is rather terse when the problem with a
> perl module is actually with something the module requires or uses.
> here's a patch which will extract a little more info from $@ if it
> can, and provide it as part of the message.  helpful for tracking
> down what is *actually* at fault..

well, in the _vast_ majority of cases I would expect the error message to
read "Can't locate...".  that's the purpose of have_module after all, to
ping if the module is there or not.

in the rare cases where the module is there but can't be loaded (such as
modules in development) it might be useful to have additional information.
but have_module() really isn't there as a development tool - that's what
perl -cw is for :)

nevertheless, it might be useful if you swapped the logic around, adding
additional $why only if the error isn't the standard "Can't locate Bar.pm in
@INC..."

HTH

--Geoff