Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
AnyEvent-I3: use Carp for easier debugging (includes stacktraces)
Browse files Browse the repository at this point in the history
  • Loading branch information
stapelberg committed Sep 13, 2017
1 parent b23e1f6 commit 72c972a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions AnyEvent-I3/lib/AnyEvent/I3.pm
Expand Up @@ -9,6 +9,7 @@ use AnyEvent::Socket;
use AnyEvent;
use Encode;
use Scalar::Util qw(tainted);
use Carp;

=head1 NAME
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 72c972a

Please sign in to comment.