« lib/Test2/Harness/UI/Schema/ResultBase.pm
↑ Summary
lib/Test2/Harness/UI/Schema/Overlay/JobField.pm »
| 1 | package Test2::Harness::UI::Util::Errors; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | our $VERSION = '0.000150'; | ||
| 6 | |||
| 7 | use Scalar::Util qw/blessed/; | ||
| 8 | |||
| 9 | use Importer Importer => 'import'; | ||
| 10 | |||
| 11 | our @EXPORT = qw/is_error_code/; | ||
| 12 | |||
| 13 | sub is_error_code { | ||
| 14 | my $thing = shift; | ||
| 15 | return undef unless blessed($thing); | ||
| 16 | return undef unless $thing->isa(__PACKAGE__); | ||
| 17 | return $$thing; | ||
| 18 | } | ||
| 19 | |||
| 20 | for my $code (400 .. 405) { | ||
| 21 | my $val = 0 + $code; | ||
| 22 | my $ref = bless \$val, __PACKAGE__; | ||
| 23 | my $name = "ERROR_$code"; | ||
| 24 | push @EXPORT => $name; | ||
| 25 | |||
| 26 | no strict 'refs'; | ||
| 27 | *{$name} = sub() { $ref }; | ||
| 28 | } | ||
| 29 | |||
| 30 | sub code { ${$_[0]} } | ||
| 31 | |||
| 32 | 1; | ||
| 33 | |||
| 34 | __END__ |