libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 52 forks source link

tick() doesn't die on error #239

Closed exercism-1 closed 6 years ago

exercism-1 commented 6 years ago

tick warns on error instead of dying, which doesn't match the documentation.

https://metacpan.org/pod/WWW::Mechanize#$mech-%3Etick(-$name,-$value-%5B,-$set%5D-):

Dies if there is no named check box for that value.

https://metacpan.org/source/OALDERS/WWW-Mechanize-1.86/lib/WWW/Mechanize.pm#L885-886:

    # got self far?  Didn't find anything
    $self->warn( qq{No checkbox "$name" for value "$value" in form} );

That means code like:

eval { $mech->tick($field, $value); }
if ($@) {
    ...
}

doesn't actually detect errors (tick never dies) and spews warnings (because eval only catches exceptions, not warnings).

oalders commented 6 years ago

Sounds like we need to have the code align with the docs. @genio thoughts?

oalders commented 6 years ago

@petdance any thoughts on how to handle this?

petdance commented 6 years ago

Seems to me the warn should be a die, because the warning isn't very useful.