p5-shorten / www-shorten

Perl interface to various URL-shortening sites
https://metacpan.org/release/WWW-Shorten
Other
12 stars 9 forks source link

Terminates program on a 503 Service Unavailable #13

Closed chrisjrob closed 8 years ago

chrisjrob commented 8 years ago

Seems to be the fault of WWW::Shorten::generic which is using WWW::Shorten::UserAgent, which seems to be designed explicitly to die on service errors, rather than using LWP::UserAgent presumably?

Not sure if that's a bug or as per design - but not ideal for server programs to die when there's a service interruption?

davorg commented 8 years ago

I added WWW::Shorten::UserAgent as I thought it was easier to throw an exception (aka "die") than dealing with returning error values through a stack of subroutine calls.

It's easy enough to stop your program from dying at that point. Use something like Try::Tiny (as the shorten example program does) or by using eval and then checking $@.

chrisjrob commented 8 years ago

Thank you very much for your response. Eval is working fine.