Ed Avis wrote:
> On 21 May 2004, Gisle Aas wrote:
> >>When LWP::Simple::get() fails it would often be useful to print a more
> >>informative error message than just 'get failed'.
> 
> >I've decided to not apply this patch.  I want to keep the
> >LWP::Simple as simple as it can be.  I recommend using the full
> >LWP::UserAgent interface if you need the extra error information.  
> >Also interfaces involving globals are not really pleasant.
> 
> My feeling is that the truly simple interface would throw an exception
> with an informative message on error, and then you wouldn't have to
> manually check the return value for each call.  But this suggestion
> wasn't well received on the list.
If you want to throw an exception fine with me, but don't use global
variables!
I'm not sure the easiest way to work with exceptions in perl, but
exceptions are not global, they are local to the function.

> You make a good point about global variables, however I felt it was
> overridden by the importance of usable error reporting.  The global $!
> for error messages is rather ugly, but still any good beginner's Perl
> tutorial recommends to always put $! in every error message.
DO NOT USE GLOBALS!!!
If a tutorial tells you to use a global variable then that's a bad
tutorial!

> At the moment I have an application which uses LWP::Simple but I'm
> having difficulty getting usable bug reports from users.  The app can
> only print 'download failed' but once you know the reason it failed
> the problem is much easier to fix.  At the moment I have to send out
> perl oneliners for the users to run to find out the problem, since
> there is no way to get LWP::Simple to return the error message.
Then, as I said in my prior post, use the "complicated" interface of
LWP.

> It looks like there is a niche for a library that makes it simple to
> download URLs, but also makes it simple to do the right thing, which
> in my opinion means always checking the success of each call and 
> giving an informative error message.
As I said there's a "complicated" interface you should be using anyway,
instead the crappy LWP::Simple.

> Might you include such a library (with interface similar to
> LWP::Simple) in the LWP bundle, or should I distribute it separately?
There's already a library.


Reply via email to