Shavenheads, I run a script regularly that crawls my various websites checking for bad links. Last night my internet connection was down and rather than just producing an error and carrying on to the next part of the script which does a whole of other useful things too, the whole script crashed. viz:

Error GETing http://www.website.com/images/billiards/brass-cross-rest- +head-PER-033.jpg: Can't connect to www.website.com:80 (Bad hostname ' +www.website.com') at nightlychecks.pl line 2346 at C:/Perl/lib/WWW/Mechanize.pm line 2705 WWW::Mechanize::_die('Error ', 'GET', 'ing ', 'URI::http=SCALAR(0x +93515dc)', ': ', 'Can\'t connect to www.website.com:80 (Bad hostname +\'www...') called at C:/Perl/lib/WWW/Mechanize.pm line 2692 WWW::Mechanize::die('WWW::Mechanize=HASH(0x934eda4)', 'Error ', 'G +ET', 'ing ', 'URI::http=SCALAR(0x93515dc)', ': ', 'Can\'t connect to +www.website.com:80 (Bad hostname \'www...') called at C:/Perl/lib/WWW +/Mechanize.pm line 2340 WWW::Mechanize::_update_page('WWW::Mechanize=HASH(0x934eda4)', 'HT +TP::Request=HASH(0x9643efc)', 'HTTP::Response=HASH(0x93531bc)') calle +d at C:/Perl/lib/WWW/Mechanize.pm line 2206 WWW::Mechanize::request('WWW::Mechanize=HASH(0x934eda4)', 'HTTP::R +equest=HASH(0x9643efc)') called at C:/Perl/lib/LWP/UserAgent.pm line +389 LWP::UserAgent::get('WWW::Mechanize=HASH(0x934eda4)', 'http://www. +website.com/images/billiards/brass-cross-rest...') called at C:/Perl/ +lib/WWW/Mechanize.pm line 407 WWW::Mechanize::get('WWW::Mechanize=HASH(0x934eda4)', 'http://www. +website.com/images/billiards/brass-cross-rest...') called at nightlyc +hecks.pl line 2346 main::webpage_assign_check() called at nightlychecks.pl line 560 main::run_report('HASH(0x6fb523c)') called at nightlychecks.pl lin +e 289 main::nightly_checks() called at nightlychecks.pl line 86

How can I make www::mechanize produce an error gracefully rather than just pegging out horrifically? The www::mechanize documentation doesn't enlighten me...


In reply to www::mechanize - how to prevent it dying? by jfrm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.