| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | Test::Run::Obj::Error - an error class hierarchy for Test::Run. | ||||||||||
| 4 | |||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||
| 6 | |||||||||||
| 7 | This module provides an error class hieararchy for Test::Run. This is used | ||||||||||
| 8 | for throwing exceptions that should be handled programatically. | ||||||||||
| 9 | |||||||||||
| 10 | =head1 METHODS | ||||||||||
| 11 | =cut | ||||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | package Test::Run::Obj::Error; | ||||||||||
| 15 | |||||||||||
| 16 | 16 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 16 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | 16 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 16 | ▶ | use Test::Run::Base::Struct; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 16 | ▶ | use Scalar::Util (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | 16 | ▶ | use vars qw(@ISA @fields); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | 16 | ▶ | use MRO::Compat; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | sub _polymorphic_stringify | ||||||||||
| 31 | 15 | ▶ | { | ||||||||
|
Subroutine
_polymorphic_stringify: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 15 | my $self = shift; | |||||||||
| 33 | 15 | return $self->stringify(@_); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | use overload | ||||||||||
| 37 | 16 | ▶ | '""' => \&_polymorphic_stringify, | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 'fallback' => 1 | ||||||||||
| 39 | 16 | ; | |||||||||
| 40 | |||||||||||
| 41 | 16 | extends(qw(Test::Run::Base::Struct)); | |||||||||
| 42 | |||||||||||
| 43 | 16 | has 'package' => (is => "rw", isa => "Str"); | |||||||||
| 44 | 16 | has 'file' => (is => "rw", isa => "Str"); | |||||||||
| 45 | 16 | has 'line' => (is => "rw", isa => "Num"); | |||||||||
| 46 | 16 | has 'text' => (is => "rw", isa => "Str"); | |||||||||
| 47 | |||||||||||
| 48 | =head2 BUILD | ||||||||||
| 49 | |||||||||||
| 50 | For Moose. | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | sub BUILD | ||||||||||
| 55 | 11 | ▶ | { | ||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 56 | 11 | my $self = shift; | |||||||||
| 57 | |||||||||||
| 58 | 11 | my ($pkg,$file,$line) = caller(1); | |||||||||
| 59 | 11 | $self->package($pkg); | |||||||||
| 60 | 11 | $self->file($file); | |||||||||
| 61 | 11 | $self->line($line); | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | =head2 $self->stringify() | ||||||||||
| 65 | |||||||||||
| 66 | Stringifies the error. Returns the text() field by default. | ||||||||||
| 67 | |||||||||||
| 68 | =cut | ||||||||||
| 69 | |||||||||||
| 70 | sub stringify | ||||||||||
| 71 | 17 | ▶ | { | ||||||||
|
Subroutine
stringify: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 72 | 17 | my $self = shift; | |||||||||
| 73 | 17 | return $self->text(); | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 16 | 1; | |||||||||
| 77 | |||||||||||
| 78 | package Test::Run::Obj::Error::TestsFail; | ||||||||||
| 79 | |||||||||||
| 80 | 16 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 81 | |||||||||||
| 82 | 16 | @ISA = (qw(Test::Run::Obj::Error)); | |||||||||
| 83 | |||||||||||
| 84 | package Test::Run::Obj::Error::TestsFail::NoTestsRun; | ||||||||||
| 85 | |||||||||||
| 86 | 16 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 87 | |||||||||||
| 88 | 16 | @ISA = (qw(Test::Run::Obj::Error::TestsFail)); | |||||||||
| 89 | |||||||||||
| 90 | package Test::Run::Obj::Error::TestsFail::Other; | ||||||||||
| 91 | |||||||||||
| 92 | 16 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 93 | |||||||||||
| 94 | 16 | @ISA = (qw(Test::Run::Obj::Error::TestsFail)); | |||||||||
| 95 | |||||||||||
| 96 | package Test::Run::Obj::Error::TestsFail::NoOutput; | ||||||||||
| 97 | |||||||||||
| 98 | 16 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 99 | |||||||||||
| 100 | 16 | @ISA = (qw(Test::Run::Obj::Error::TestsFail)); | |||||||||
| 101 | |||||||||||
| 102 | package Test::Run::Obj::Error::TestsFail::Bailout; | ||||||||||
| 103 | |||||||||||
| 104 | 16 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | 16 | extends(qw(Test::Run::Obj::Error::TestsFail)); | |||||||||
| 108 | |||||||||||
| 109 | 16 | has 'bailout_reason' => (is => "rw", isa => "Str"); | |||||||||
| 110 | |||||||||||
| 111 | sub stringify | ||||||||||
| 112 | 7 | ▶ | { | ||||||||
|
Subroutine
stringify: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 113 | 7 | my $self = shift; | |||||||||
| 114 | 7 | ▶ | return "FAILED--Further testing stopped" . | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | ($self->bailout_reason() ? | ||||||||||
| 116 | (": " . $self->bailout_reason() . "\n") : | ||||||||||
| 117 | ".\n" | ||||||||||
| 118 | ); | ||||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | package Test::Run::Obj::Error::Straps; | ||||||||||
| 122 | |||||||||||
| 123 | 16 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 124 | |||||||||||
| 125 | 16 | @ISA = (qw(Test::Run::Obj::Error)); | |||||||||
| 126 | |||||||||||
| 127 | package Test::Run::Obj::Error::Straps::CannotRunPerl; | ||||||||||
| 128 | |||||||||||
| 129 | 16 | ▶ | use vars qw(@ISA); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 130 | |||||||||||
| 131 | 16 | @ISA = (qw(Test::Run::Obj::Error::Straps)); | |||||||||
| 132 | |||||||||||
| 133 | 16 | 1; | |||||||||
| 134 | |||||||||||
| 135 | =head1 LICENSE | ||||||||||
| 136 | |||||||||||
| 137 | This file is licensed under the MIT X11 License: | ||||||||||
| 138 | |||||||||||
| 139 | http://www.opensource.org/licenses/mit-license.php | ||||||||||
| 140 | |||||||||||
| 141 | =cut | ||||||||||
| 142 | |||||||||||