| 1 | package Parse::StackTrace::Type::Python; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 2 | extends 'Parse::StackTrace'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use constant HAS_TRACE => qr/^\s*File\s".+"(?:,|\s+in)/ms; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use constant EXCEPTION_REGEX => qr/ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | ^ | ||||||||||||||||||||||||||||
| 11 | (?:Exception \s Type:\s+)? # Django Format | ||||||||||||||||||||||||||||
| 12 | \S*(?:Error|Exception) # Actual Exception | ||||||||||||||||||||||||||||
| 13 | (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) | ||||||||||||||||||||||||||||
| 14 | 2 | /x; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 10 | ▶ | sub thread_number { | ||||||||||||||||||||||||||
|
Subroutine
thread_number: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 10 | my ($self, $number) = @_; | |||||||||||||||||||||||||||
| 18 | 10 | ▶ | return $self->threads->[0] if $number == 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 5 | return undef; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 67 | ▶ | sub _handle_block { | ||||||||||||||||||||||||||
|
Subroutine
_handle_block: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 23 | 67 | my $class = shift; | |||||||||||||||||||||||||||
| 24 | 67 | my %params = @_; | |||||||||||||||||||||||||||
| 25 | my ($frame_lines, $current_thread, $lines, $end, $debug) = | ||||||||||||||||||||||||||||
| 26 | 67 | @params{qw(frame_lines thread lines end_line_number debug)}; | |||||||||||||||||||||||||||
| 27 | # If we run into the description of the exception, then we're done parsing | ||||||||||||||||||||||||||||
| 28 | # the trace, provided that we've already parsed some frames. | ||||||||||||||||||||||||||||
| 29 | 67 | my $first_line = $frame_lines->[0]; | |||||||||||||||||||||||||||
| 30 | 67 | ▶ | if (scalar @{ $current_thread->frames } and $first_line =~ EXCEPTION_REGEX) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
scalar @{$current_thread->frames;} and $first_line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
MC/DC100%2/2
scalar @{$current_thread->frames;} and $first_line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
scalar @{$current_thread->frames;}
$first_line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
Truth table100%3/3
A and B
A= scalar @{$current_thread->frames;}B= $first_line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
| |||||||||||||||||||||||||||||
| 31 | 5 | $current_thread->{description} = trim($first_line); | |||||||||||||||||||||||||||
| 32 | 5 | ▶ | print STDERR "Thread Exception: $first_line\n" if $debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 5 | pop @$frame_lines; | |||||||||||||||||||||||||||
| 34 | # Don't parse anymore. | ||||||||||||||||||||||||||||
| 35 | 5 | @$lines = (); | |||||||||||||||||||||||||||
| 36 | 5 | $current_thread->ending_line($end); | |||||||||||||||||||||||||||
| 37 | 5 | return $current_thread; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 62 | return $class->SUPER::_handle_block(@_); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 53 | ▶ | sub _next_line_ends_frame { | ||||||||||||||||||||||||||
|
Subroutine
_next_line_ends_frame: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 44 | 53 | my $class = shift; | |||||||||||||||||||||||||||
| 45 | 53 | my ($line) = @_; | |||||||||||||||||||||||||||
| 46 | 53 | ▶ | return ($class->SUPER::_next_line_ends_frame(@_) | ||||||||||||||||||||||||||
|
Condition100%3/3
$class->SUPER::_next_line_ends_frame(@_) || $line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
MC/DC100%2/2
$class->SUPER::_next_line_ends_frame(@_) || $line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
$class->SUPER::_next_line_ends_frame(@_)
$line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
Truth table100%3/3
A || B
A= $class->SUPER::_next_line_ends_frame(@_)B= $line =~ /
^
(?:Exception \s Type:\s+)? # Django Format
\S*(?:Error|Exception) # Actual Exception
(?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
/x
| |||||||||||||||||||||||||||||
| 47 | or $line =~ EXCEPTION_REGEX); | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 5 | ▶ | sub trim { | ||||||||||||||||||||||||||
|
Subroutine
trim: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 5 | my $str = shift; | |||||||||||||||||||||||||||
| 52 | 5 | $str =~ s/^s*//; | |||||||||||||||||||||||||||
| 53 | 5 | $str =~ s/\s*$//; | |||||||||||||||||||||||||||
| 54 | 5 | return $str; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 2 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||