/usr/share/perl5/Object/InsideOut/Exception.pm is in libobject-insideout-perl 3.87-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | package Object::InsideOut::Exception; {
use strict;
use warnings;
our $VERSION = '3.87';
$VERSION = eval $VERSION;
# Exceptions generated by this module
use Exception::Class 1.29 (
'OIO' => {
'description' => 'Generic Object::InsideOut exception',
# First 3 fields must be: 'Package', 'File', 'Line'
'fields' => ['Error', 'Chain'],
},
'OIO::Code' => {
'isa' => 'OIO',
'description' =>
'Object::InsideOut exception that indicates a coding error',
'fields' => ['Info', 'Code'],
},
'OIO::Internal' => {
'isa' => 'OIO::Code',
'description' =>
'Object::InsideOut exception that indicates a internal problem',
'fields' => ['Code', 'Declaration'],
},
'OIO::Attribute' => {
'isa' => 'OIO::Code',
'description' =>
'Object::InsideOut exception that indicates a coding error',
'fields' => ['Attribute'],
},
'OIO::Method' => {
'isa' => 'OIO',
'description' =>
'Object::InsideOut exception that indicates an method calling error',
},
'OIO::Args' => {
'isa' => 'OIO::Method',
'description' =>
'Object::InsideOut exception that indicates an argument error',
'fields' => ['Usage', 'Arg'],
},
'OIO::Args::Unhandled' => {
'isa' => 'OIO::Args',
'description' =>
'Object::InsideOut exception that indicates an unhandled argument',
'fields' => ['Usage', 'Arg'],
},
'OIO::Runtime' => {
'isa' => 'OIO::Code',
'description' =>
'Object::InsideOut exception that indicates a runtime error',
'fields' => ['Class1', 'Class2'],
},
);
# Turn on stack trace by default
OIO->Trace(1);
# A 'throw' method that adds location information to the exception object
sub OIO::die
{
my $class = shift;
my %args = @_;
# Report on ourself?
my $report_self = delete($args{'self'});
# Ignore ourselves in stack trace, unless told not to
if (! $report_self) {
my @ignore = ('Object::InsideOut::Exception', 'Object::InsideOut');
if (exists($args{'ignore_package'})) {
if (ref($args{'ignore_package'})) {
push(@ignore, @{$args{'ignore_package'}});
} else {
push(@ignore, $args{'ignore_package'});
}
}
$args{'ignore_package'} = \@ignore;
}
# Remove any location information
my $location = delete($args{'location'});
# Create exception object
my $e = $class->new(%args);
# Override location information, if applicable
if ($location) {
$e->{'package'} = $$location[0];
$e->{'file'} = $$location[1];
$e->{'line'} = $$location[2];
}
# If reporting on ourself, then correct location info
elsif ($report_self) {
my $frame = $e->trace->frame(1);
$e->{'package'} = $frame->package();
$e->{'line'} = $frame->line();
$e->{'file'} = $frame->filename();
}
# Throw error
no strict 'refs';
no warnings 'once';
if (${$class.'::WARN_ONLY'}) {
warn $e->OIO::full_message();
} else {
$e->throw(%args);
}
}
# Provides a fully formated error message for the exception object
sub OIO::full_message
{
my $self = shift;
# Start with error class and message
my $msg = ref($self) . ' error: ' . $self->message();
chomp($msg);
# Add fields, if any
my @fields = $self->Fields();
foreach my $field (@fields) {
next if ($field eq 'Chain');
if (exists($self->{$field})) {
$msg .= "\n$field: " . $self->{$field};
chomp($msg);
}
}
# Add location
$msg .= "\nPackage: " . $self->package()
. "\nFile: " . $self->file()
. "\nLine: " . $self->line();
# Chained error messages
if (exists($self->{'Chain'})) {
my $chain = OIO::full_message($self->{'Chain'});
chomp($chain);
$chain =~ s/^/ /mg;
$msg .= "\n\nSubsequent to the above, the following error also occurred:\n"
. $chain;
}
return ($msg . "\n");
}
# Catch untrapped errors
# Usage: local $SIG{'__DIE__'} = 'OIO::trap';
sub OIO::trap
{
# Just rethrow if already an exception object
if (Object::InsideOut::Util::is_it($_[0], 'Exception::Class::Base')) {
die($_[0]);
}
# Package the error into an object
OIO->die(
'location' => [ caller() ],
'message' => 'Trapped uncaught error',
'Error' => join('', @_));
}
# Combine errors into a single error object
sub OIO::combine
{
my ($err1, $err2) = @_;
# Massage second error, if needed
if ($err2 && ! ref($err2)) {
my $e = OIO->new(
'message' => "$err2",
'ignore_package' => [ 'Object::InsideOut::Exception' ]
);
my $frame = $e->trace->frame(1);
$e->{'package'} = $frame->package();
$e->{'line'} = $frame->line();
$e->{'file'} = $frame->filename();
$err2 = $e;
}
# Massage first error, if needed
if ($err1) {
if (! ref($err1)) {
my $e = OIO->new(
'message' => "$err1",
'ignore_package' => [ 'Object::InsideOut::Exception' ]
);
my $frame = $e->trace->frame(1);
$e->{'package'} = $frame->package();
$e->{'line'} = $frame->line();
$e->{'file'} = $frame->filename();
$err1 = $e;
}
# Combine errors, if possible
if ($err2) {
if (Object::InsideOut::Util::is_it($err1, 'OIO')) {
$err1->{'Chain'} = $err2;
} else {
warn($err2); # Can't combine
}
}
} else {
$err1 = $err2;
undef($err2);
}
return ($err1);
}
} # End of package's lexical scope
1;
|