summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/CollapseStack.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Reply/Plugin/CollapseStack.pm')
-rw-r--r--lib/Reply/Plugin/CollapseStack.pm69
1 files changed, 27 insertions, 42 deletions
diff --git a/lib/Reply/Plugin/CollapseStack.pm b/lib/Reply/Plugin/CollapseStack.pm
index e60c0f5..51cd4fc 100644
--- a/lib/Reply/Plugin/CollapseStack.pm
+++ b/lib/Reply/Plugin/CollapseStack.pm
@@ -1,9 +1,9 @@
-package Reply::Plugin::CollapseStack;
+package main;
use strict;
use warnings;
# ABSTRACT: display error stack traces only on demand
-use base 'Reply::Plugin';
+use mop;
{
local @SIG{qw(__DIE__ __WARN__)};
@@ -26,54 +26,39 @@ the C<num_lines> option.
=cut
-sub new {
- my $class = shift;
- my %opts = @_;
+class Reply::Plugin::CollapseStack extends Reply::Plugin {
+ has $num_lines = 1;
- my $self = $class->SUPER::new(@_);
- $self->{num_lines} = $opts{num_lines} || 1;
+ has $full_error;
- return $self;
-}
-
-sub compile {
- my $self = shift;
- my ($next, @args) = @_;
-
- local $SIG{__DIE__} = \&Carp::Always::_die;
- $next->(@args);
-}
-
-sub execute {
- my $self = shift;
- my ($next, @args) = @_;
-
- local $SIG{__DIE__} = \&Carp::Always::_die;
- $next->(@args);
-}
-
-sub mangle_error {
- my $self = shift;
- my $error = shift;
-
- $self->{full_error} = $error;
+ method compile ($next, @args) {
+ local $SIG{__DIE__} = \&Carp::Always::_die;
+ $next->(@args);
+ }
- my @lines = split /\n/, $error;
- if (@lines > $self->{num_lines}) {
- splice @lines, $self->{num_lines};
- $error = join "\n", @lines, " (Run #stack to see the full trace)\n";
+ method execute ($next, @args) {
+ local $SIG{__DIE__} = \&Carp::Always::_die;
+ $next->(@args);
}
- return $error;
-}
+ method mangle_error ($error) {
+ $full_error = $error;
-sub command_stack {
- my $self = shift;
+ my @lines = split /\n/, $error;
+ if (@lines > $num_lines) {
+ splice @lines, $num_lines;
+ $error = join "\n", @lines,
+ " (Run #stack to see the full trace)\n";
+ }
- # XXX should use print_error here
- print($self->{full_error} || "No stack to display.\n");
+ return $error;
+ }
- return '';
+ method command_stack {
+ # XXX should use print_error here
+ print($self->{full_error} || "No stack to display.\n");
+ return '';
+ }
}
=for Pod::Coverage