mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Improve conversion of C exceptions to Exception objects.
Colons in the message would prevent all of the message from being loaded into the Exception object.
This commit is contained in:
parent
599e291b36
commit
4fb75c9cc1
@ -102,6 +102,10 @@
|
||||
<release-item>
|
||||
<p>Check <code>int</code> size in <code>common/type.h</code>. This ensures that integers are at least 32-bits without having to run the test suite.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Improve conversion of C exceptions to <code>Exception</code> objects. Colons in the message would prevent all of the message from being loaded into the <code>Exception</code> object.</p>
|
||||
</release-item>
|
||||
</release-development-list>
|
||||
</release-core-list>
|
||||
|
||||
|
@ -118,9 +118,17 @@ sub isException
|
||||
# Else if a specially formatted string from the C library
|
||||
elsif ($$roException =~ /^PGBRCLIB\:[0-9]+\:/)
|
||||
{
|
||||
# Split message and discard the first part used for identification
|
||||
my @stryException = split(/\:/, $$roException);
|
||||
$$roException = new pgBackRest::Common::Exception(
|
||||
"ERROR", $stryException[1] + 0, $stryException[4], $stryException[2] . qw{:} . $stryException[3]);
|
||||
shift(@stryException);
|
||||
|
||||
# Construct exception fields
|
||||
my $iCode = shift(@stryException) + 0;
|
||||
my $strTrace = shift(@stryException) . qw{:} . shift(@stryException);
|
||||
my $strMessage = join(':', @stryException);
|
||||
|
||||
# Create exception
|
||||
$$roException = new pgBackRest::Common::Exception("ERROR", $iCode, $strMessage, $strTrace);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1226,7 +1226,11 @@ eval
|
||||
or do
|
||||
{
|
||||
# If a backrest exception then return the code
|
||||
exit $EVAL_ERROR->code() if (isException(\$EVAL_ERROR));
|
||||
if (isException(\$EVAL_ERROR))
|
||||
{
|
||||
syswrite(*STDOUT, $EVAL_ERROR->message() . "\n" . $EVAL_ERROR->trace());
|
||||
exit $EVAL_ERROR->code();
|
||||
}
|
||||
|
||||
# Else output the unhandled error
|
||||
syswrite(*STDOUT, $EVAL_ERROR);
|
||||
|
Loading…
Reference in New Issue
Block a user