]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Tools.pm
LaTeX::TikZ::Tools::type_constraint shouldn't croak when it can't find the .pm file
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Tools.pm
index 4475e82e7aae4103c3b3aa1590ee94725fe4df76..54e50097d13408746b1c526c33101bde775d1a1a 100644 (file)
@@ -9,11 +9,11 @@ LaTeX::TikZ::Tools - Miscellaneous tools for LaTeX::TikZ classes.
 
 =head1 VERSION
 
-Version 0.01
+Version 0.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 use Any::Moose 'Util::TypeConstraints' => [ 'find_type_constraint' ];
 
@@ -51,7 +51,7 @@ sub numround {
 
 =head2 C<type_constraint $class>
 
-Find the type constraint for C<$class> by loading the relevant F<.pm> file beforehand.
+Find the type constraint for C<$class> by first trying to load the relevant F<.pm> file.
 
 =cut
 
@@ -61,7 +61,13 @@ sub type_constraint {
  my $file = $class;
  $file =~ s{::}{/}g;
  $file .= '.pm';
- require $file;
+ unless ($INC{$file}) {
+  local $@;
+  eval {
+   local $SIG{__DIE__}; # See LaTeX::TikZ::Meta::TypeConstraint::Autocoerce
+   require $file;
+  }
+ }
 
  find_type_constraint($class);
 }