From: Michael Stapelberg Date: Wed, 13 Sep 2017 14:39:44 +0000 (+0200) Subject: AnyEvent-I3: use Carp for easier debugging (includes stacktraces) X-Git-Tag: 4.15~91^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=72c972a36c187584106c8792b8930d2aba468448;p=i3%2Fi3 AnyEvent-I3: use Carp for easier debugging (includes stacktraces) --- diff --git a/AnyEvent-I3/lib/AnyEvent/I3.pm b/AnyEvent-I3/lib/AnyEvent/I3.pm index 75845ccd..8598f850 100644 --- a/AnyEvent-I3/lib/AnyEvent/I3.pm +++ b/AnyEvent-I3/lib/AnyEvent/I3.pm @@ -9,6 +9,7 @@ use AnyEvent::Socket; use AnyEvent; use Encode; use Scalar::Util qw(tainted); +use Carp; =head1 NAME @@ -186,7 +187,7 @@ sub new { # We use getpwuid() instead of $ENV{HOME} because the latter is tainted # and thus produces warnings when running tests with perl -T my $home = (getpwuid($<))[7]; - die "Could not get home directory" unless $home and -d $home; + confess "Could not get home directory" unless $home and -d $home; $path =~ s/~/$home/g; } @@ -330,9 +331,9 @@ scalar), if specified. sub message { my ($self, $type, $content) = @_; - die "No message type specified" unless defined($type); + confess "No message type specified" unless defined($type); - die "No connection to i3" unless defined($self->{ipchdl}); + confess "No connection to i3" unless defined($self->{ipchdl}); my $payload = ""; if ($content) { @@ -373,7 +374,7 @@ sub _ensure_connection { return if defined($self->{ipchdl}); - $self->connect->recv or die "Unable to connect to i3 (socket path " . $self->{path} . ")"; + $self->connect->recv or confess "Unable to connect to i3 (socket path " . $self->{path} . ")"; } =head2 get_workspaces