croak "The format argument ($format) not accepted.\n" .
"Please pass a valid format (oaidc, srwdc, or rdfdc)\n";
}
- my $err = $xslt_engine->err; # error number
- my $errstr = $xslt_engine->errstr; # error message
+ my $err = $xslt_engine->err; # error code
if ( $err ) {
- croak "Error when processing $errstr Error number: $err\n";
+ croak "Error $err while processing\n";
} else {
return $output;
}
--- /dev/null
+[% SWITCH code %]
+ [% CASE 'XSLTH_ERR_NO_FILE' %]
+ No XSLT file passed.
+ [% CASE 'XSLTH_ERR_FILE_NOT_FOUND' %]
+ XSLT file not found.
+ [% CASE 'XSLTH_ERR_LOADING' %]
+ Error while loading stylesheet.
+ [% CASE 'XSLTH_ERR_PARSING_CODE' %]
+ Error while parsing stylesheet.
+ [% CASE 'XSLTH_ERR_PARSING_DATA' %]
+ Error while parsing input.
+ [% CASE 'XSLTH_ERR_TRANSFORMING' %]
+ Error while transforming input.
+ [% CASE 'XSLTH_NO_STRING_PASSED' %]
+ No string to transform.
+[% END %]
[% FOREACH errcon IN errconn %]
[% IF ( errcon.error == '10000' ) %]<li>Connection failed to [% errcon.server %]</li>
[% ELSIF ( errcon.error == '10007' ) %]<li>Connection timeout to [% errcon.server %]</li>
- [% ELSIF ( errcon.error == 'xslt_err' ) %]<li>[% errcon.server %]: Warning: XSLT error on search result [% errcon.seq %]</li>
+ [% ELSIF errcon.error.match( '^XSLTH' ) %]<li>[% errcon.server %] record [% errcon.seq %]: [% PROCESS 'xslt-handler.inc' code=errcon.error %]</li>
[% ELSE %]<li>[% errcon.server %] record [% errcon.seq %]: [% errcon.error %]</li>
[% END %]
[% END %]
[% INCLUDE 'z3950_search.inc' %]
[% END %]
-[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
\ No newline at end of file
+[% INCLUDE 'intranet-bottom.inc' popup_window=1 %]
--- /dev/null
+[% SWITCH code %]
+ [% CASE 'XSLTH_ERR_NO_FILE' %]
+ No XSLT file passed.
+ [% CASE 'XSLTH_ERR_FILE_NOT_FOUND' %]
+ XSLT file not found.
+ [% CASE 'XSLTH_ERR_LOADING' %]
+ Error while loading stylesheet.
+ [% CASE 'XSLTH_ERR_PARSING_CODE' %]
+ Error while parsing stylesheet.
+ [% CASE 'XSLTH_ERR_PARSING_DATA' %]
+ Error while parsing input.
+ [% CASE 'XSLTH_ERR_TRANSFORMING' %]
+ Error while transforming input.
+ [% CASE 'XSLTH_NO_STRING_PASSED' %]
+ No string to transform.
+[% END %]
};
#Group 3: testing _do_xslt_proc (part of Z3950Search)
subtest '_do_xslt_proc' => sub {
- plan tests => 7;
+ plan tests => 6;
test_do_xslt();
};
#ready for the main test
my @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine );
- is( $res[1] && $res[1] eq 'xslt_err', undef,
- 'Check error code of _do_xslt_proc');
- if( !$res[1] ) {
- is( ref $res[0] eq 'MARC::Record', 1, 'Got back MARC record');
- my $sub = $res[0]->subfield('990','a')//'';
- is( $sub eq 'I saw you', 1, 'Found 990a in the record');
- } else {
- ok( 1, 'Skipped one test');
- ok( 1, 'Skipped another one');
- }
+ is( $res[1], undef, 'No error returned' );
+ is( ref $res[0], 'MARC::Record', 'Got back MARC record');
+ is( $res[0]->subfield('990','a'), 'I saw you', 'Found 990a in the record');
#forcing an error on the xslt side
$server->{add_xslt} = 'notafile.xsl';
- warning_like
- { @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine ) }
- qr/^XSLT file not found./,
- '_do_xslt_proc warns it XSLT_handler problem';
- is( $res[1] && $res[1] eq 'xslt_err', 1,
- 'Check error code again');
+ @res = C4::Breeding::_do_xslt_proc( $biblio, $server, $engine );
+ is( $res[1], Koha::XSLT_Handler::XSLTH_ERR_2, 'Error code found' );
#We still expect the original record back
- is( ref $res[0] eq 'MARC::Record', 1, 'Still got back MARC record');
- is ( $res[0]->subfield('245','a') eq 'Just a title', 1,
+ is( ref $res[0], 'MARC::Record', 'Still got back MARC record' );
+ is ( $res[0]->subfield('245','a'), 'Just a title',
'At least the title is the same :)' );
}