]> git.vpit.fr Git - perl/modules/indirect.git/commitdiff
Make the default error message public
authorVincent Pit <vince@profvince.com>
Tue, 14 Jul 2009 12:36:46 +0000 (14:36 +0200)
committerVincent Pit <vince@profvince.com>
Tue, 14 Jul 2009 12:36:46 +0000 (14:36 +0200)
lib/indirect.pm

index 63df3d8e919489e3a196a1a1a738b37997ebf978..53dc846c35692076b047854e0aafa6f41e031276 100644 (file)
@@ -86,10 +86,6 @@ Otherwise, a warning will be emitted for each indirect construct.
 
 =cut
 
 
 =cut
 
-my $msg = sub {
- "Indirect call of method \"$_[1]\" on object \"$_[0]\" at $_[2] line $_[3].\n"
-};
-
 sub unimport {
  shift;
 
 sub unimport {
  shift;
 
@@ -99,11 +95,11 @@ sub unimport {
   if ($arg eq 'hook') {
    $hook = shift;
   } elsif ($arg eq ':fatal') {
   if ($arg eq 'hook') {
    $hook = shift;
   } elsif ($arg eq ':fatal') {
-   $hook = sub { die $msg->(@_) };
+   $hook = sub { die msg(@_) };
   }
   last if $hook;
  }
   }
   last if $hook;
  }
- $hook = sub { warn $msg->(@_) } unless defined $hook;
+ $hook = sub { warn msg(@_) } unless defined $hook;
 
  $^H |= 0x00020000;
  $^H{+(__PACKAGE__)} = _tag($hook);
 
  $^H |= 0x00020000;
  $^H{+(__PACKAGE__)} = _tag($hook);
@@ -122,6 +118,18 @@ sub import {
  ();
 }
 
  ();
 }
 
+=head1 FUNCTIONS
+
+=head2 C<msg $object, $method, $file, $line>
+
+Returns the default error message generated by C<indirect> when an invalid construct is reported.
+
+=cut
+
+sub msg {
+ "Indirect call of method \"$_[1]\" on object \"$_[0]\" at $_[2] line $_[3].\n"
+};
+
 =head1 CONSTANTS
 
 =head2 C<I_THREADSAFE>
 =head1 CONSTANTS
 
 =head2 C<I_THREADSAFE>