Permalink
Browse files

[rt #77173] improve error reporting on an API version mismatch

  • Loading branch information...
1 parent bdd4c63 commit 38742a130cd34135e9927f55575cf10f93ef1601 @tonycoz committed May 24, 2012
Showing with 24 additions and 5 deletions.
  1. +7 −0 Changes
  2. +2 −1 Imager.pm
  3. +6 −4 imext.h
  4. +9 −0 lib/Imager/API.pod
View
@@ -3,6 +3,13 @@ Imager release history. Older releases can be found in Changes.old
- eliminate the old IIM_new(), IIM_DESTROY() names from Imager's
internals, those names only matter for the XS interface.
+ - improve error reporting when PERL_INITIALIZE_IMAGER_CALLBACKS finds
+ the API level compiled into a loadable module such as
+ Imager::File::GIF doesn't match that of Imager. Previously it
+ could be difficult to determine exactly which module was failing to
+ load.
+ https://rt.cpan.org/Ticket/Display.html?id=77173
+
Imager 0.90 - 30 Apr 2012
===========
View
@@ -1605,10 +1605,11 @@ sub _load_file {
return 1;
}
else {
- my $work = $@ || "Unknown error loading $file";
+ my $work = $@ || "Unknown error";
chomp $work;
$work =~ s/\n?Compilation failed in require at .*Imager\.pm line .*\z//m;
$work =~ s/\n/\\n/g;
+ $work =~ s/\s*\.?\z/ loading $file/;
$file_load_errors{$file} = $work;
$$error = $work;
return 0;
View
10 imext.h
@@ -12,19 +12,21 @@ extern im_ext_funcs *imager_function_ext_table;
#define IMAGER_MIN_API_LEVEL IMAGER_API_LEVEL
#endif
-#define PERL_INITIALIZE_IMAGER_CALLBACKS \
+#define PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(name) \
do { \
imager_function_ext_table = INT2PTR(im_ext_funcs *, SvIV(get_sv(PERL_FUNCTION_TABLE_NAME, 1))); \
if (!imager_function_ext_table) \
croak("Imager API function table not found!"); \
if (imager_function_ext_table->version != IMAGER_API_VERSION) { \
- croak("Imager API version incorrect loaded %d vs expected %d", \
- imager_function_ext_table->version, IMAGER_API_VERSION); \
+ croak("Imager API version incorrect loaded %d vs expected %d in %s", \
+ imager_function_ext_table->version, IMAGER_API_VERSION, (name)); \
} \
if (imager_function_ext_table->level < IMAGER_MIN_API_LEVEL) \
- croak("API level %d below minimum of %d", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL); \
+ croak("API level %d below minimum of %d in %s", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL, (name)); \
} while (0)
+#define PERL_INITIALIZE_IMAGER_CALLBACKS PERL_INITIALIZE_IMAGER_CALLBACKS_NAME(__FILE__)
+
/* just for use here */
#define im_extt imager_function_ext_table
View
@@ -14,7 +14,10 @@ Imager::API - Imager's C API - introduction.
...
BOOT:
+ /* any release with the API */
PERL_INITIALIZE_IMAGER_CALLBACKS;
+ /* preferred from Imager 0.91 */
+ PERL_INITIALIZE_IMAGER_CALLBACKS_NAME("My::Module");
=head1 DESCRIPTION
@@ -189,6 +192,12 @@ initialize the callback table in your C<BOOT> code:
BOOT:
PERL_INITIALIZE_IMAGER_CALLBACKS;
+From Imager 0.91 you can supply your module name to improve error
+reporting:
+
+ BOOT:
+ PERL_INITIALIZE_IMAGER_CALLBACKS_NAME("My::Module");
+
=back
=head2 foo.c

0 comments on commit 38742a1

Please sign in to comment.