]> git.ipfire.org Git - thirdparty/git.git/blob - perl/Git/LoadCPAN/Error.pm
perl: update our copy of Mail::Address
[thirdparty/git.git] / perl / Git / LoadCPAN / Error.pm
1 package Git::LoadCPAN::Error;
2 use 5.008;
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 Git::LoadCPAN::Error - Wrapper for the L<Error> module, in case it's not installed
9
10 =head1 DESCRIPTION
11
12 Wraps the import function for the L<Error> module.
13
14 This module is only intended to be used for code shipping in the
15 C<git.git> repository. Use it for anything else at your peril!
16
17 =cut
18
19 sub import {
20 shift;
21 my $caller = caller;
22
23 eval {
24 require Error;
25 1;
26 } or do {
27 my $error = $@ || "Zombie Error";
28
29 my $Git_Error_pm_path = $INC{"Git/LoadCPAN/Error.pm"} || die "BUG: Should have our own path from %INC!";
30
31 require File::Basename;
32 my $Git_Error_pm_root = File::Basename::dirname($Git_Error_pm_path) || die "BUG: Can't figure out lib/Git dirname from '$Git_Error_pm_path'!";
33
34 require File::Spec;
35 my $Git_pm_FromCPAN_root = File::Spec->catdir($Git_Error_pm_root, '..', 'FromCPAN');
36 die "BUG: '$Git_pm_FromCPAN_root' should be a directory!" unless -d $Git_pm_FromCPAN_root;
37
38 local @INC = ($Git_pm_FromCPAN_root, @INC);
39 require Error;
40 };
41
42 unshift @_, $caller;
43 goto &Error::import;
44 }
45
46 1;