Subject: | die() in constructor considered suboptimal |
In building an app around Net::Stomp and POE::Component::MessageQueue, I
noticed the following lines in Net/Stomp.pm:
19 die "Error connecting to " . $self->hostname . ':' . $self->port .
": $!"
20 unless $socket;
Calling die() in a module should be generally considered a no-no. Far
better would seem to perhaps Carp::carp() and then return undef for the
object constructor.
It is easily worked around by users by wrapping the constructor in an
eval {} block (which I've done), but it seems sort of rude to kill a
user's app without permission, as perhaps not being able to connect to
the Stomp server is not a fatal error to the object consumer :-)