mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-30 05:39:12 +02:00
Create a master list of errors in build/error.yaml.
The C and Perl errors lists are created automatically by Build.pm so they stay up to date.
This commit is contained in:
parent
eba31fbfe5
commit
1659598cfe
@ -19,7 +19,7 @@ env:
|
|||||||
- PGB_CI="doc"
|
- PGB_CI="doc"
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get -qq update && sudo apt-get install libxml-checker-perl libdbd-pg-perl libperl-critic-perl libtemplate-perl libpod-coverage-perl libtest-differences-perl libhtml-parser-perl lintian debhelper txt2man devscripts libjson-perl libio-socket-ssl-perl libxml-libxml-perl python-pip
|
- sudo apt-get -qq update && sudo apt-get install libxml-checker-perl libdbd-pg-perl libperl-critic-perl libtemplate-perl libpod-coverage-perl libtest-differences-perl libhtml-parser-perl lintian debhelper txt2man devscripts libjson-perl libio-socket-ssl-perl libxml-libxml-perl libyaml-perl python-pip
|
||||||
- |
|
- |
|
||||||
# Install & Configure AWS CLI
|
# Install & Configure AWS CLI
|
||||||
pip install --upgrade --user awscli
|
pip install --upgrade --user awscli
|
||||||
|
93
build/error.yaml
Normal file
93
build/error.yaml
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# Error Definitions
|
||||||
|
#
|
||||||
|
# Master file for all errors in the C and Perl code. For C, errors are written to src/common/error.auto.c/h. For Perl, errors are
|
||||||
|
# written to lib/pgBackRest/Common/ExceptionAuto.pm.
|
||||||
|
|
||||||
|
# Errors in the code that it should not be possible for the user to encounter -- i.e., a likely bug
|
||||||
|
assert: 25
|
||||||
|
|
||||||
|
checksum: 26
|
||||||
|
config: 27
|
||||||
|
file-invalid: 28
|
||||||
|
format: 29
|
||||||
|
command-required: 30
|
||||||
|
option-invalid: 31
|
||||||
|
option-invalid-value: 32
|
||||||
|
option-invalid-range: 33
|
||||||
|
option-invalid-pair: 34
|
||||||
|
option-duplicate-key: 35
|
||||||
|
option-negate: 36
|
||||||
|
option-required: 37
|
||||||
|
postmaster-running: 38
|
||||||
|
protocol: 39
|
||||||
|
path-not-empty: 40
|
||||||
|
file-open: 41
|
||||||
|
file-read: 42
|
||||||
|
param-required: 43
|
||||||
|
archive-mismatch: 44
|
||||||
|
archive-duplicate: 45
|
||||||
|
version-not-supported: 46
|
||||||
|
path-create: 47
|
||||||
|
command-invalid: 48
|
||||||
|
host-connect: 49
|
||||||
|
lock-acquire: 50
|
||||||
|
backup-mismatch: 51
|
||||||
|
file-sync: 52
|
||||||
|
path-open: 53
|
||||||
|
path-sync: 54
|
||||||
|
file-missing: 55
|
||||||
|
db-connect: 56
|
||||||
|
db-query: 57
|
||||||
|
db-mismatch: 58
|
||||||
|
db-timeout: 59
|
||||||
|
file-remove: 60
|
||||||
|
path-remove: 61
|
||||||
|
stop: 62
|
||||||
|
term: 63
|
||||||
|
file-write: 64
|
||||||
|
protocol-timeout: 66
|
||||||
|
feature-not-supported: 67
|
||||||
|
archive-command-invalid: 68
|
||||||
|
link-expected: 69
|
||||||
|
link-destination: 70
|
||||||
|
tablespace-in-pgdata: 71
|
||||||
|
host-invalid: 72
|
||||||
|
path-missing: 73
|
||||||
|
file-move: 74
|
||||||
|
backup-set-invalid: 75
|
||||||
|
tablespace-map: 76
|
||||||
|
path-type: 77
|
||||||
|
link-map: 78
|
||||||
|
file-close: 79
|
||||||
|
db-missing: 80
|
||||||
|
db-invalid: 81
|
||||||
|
archive-timeout: 82
|
||||||
|
file-mode: 83
|
||||||
|
option-multiple-value: 84
|
||||||
|
protocol-output-required: 85
|
||||||
|
link-open: 86
|
||||||
|
archive-disabled: 87
|
||||||
|
file-owner: 88
|
||||||
|
user-missing: 89
|
||||||
|
option-command: 90
|
||||||
|
group-missing: 91
|
||||||
|
path-exists: 92
|
||||||
|
file-exists: 93
|
||||||
|
|
||||||
|
# Memory allocation failed
|
||||||
|
memory: 94
|
||||||
|
|
||||||
|
cipher: 95
|
||||||
|
param-invalid: 96
|
||||||
|
|
||||||
|
# This error should not be thrown directly -- it serves as a parent for the C errors
|
||||||
|
runtime: 122
|
||||||
|
|
||||||
|
# Error used when an invalid error code is passed to the Perl Exception object -- this should not happen
|
||||||
|
invalid: 123
|
||||||
|
|
||||||
|
# Used when a native Perl error is not caught before exitSafe() -- this should not happen
|
||||||
|
unhandled: 124
|
||||||
|
|
||||||
|
# Used when a specific error is not provided in the Perl code. This should be rare.
|
||||||
|
unknown: 125
|
@ -48,6 +48,7 @@ sub buildAll
|
|||||||
my $rhFile = $rhBuild->{$strBuild}{&BLD_DATA}{&BLD_FILE}{$strFile};
|
my $rhFile = $rhBuild->{$strBuild}{&BLD_DATA}{&BLD_FILE}{$strFile};
|
||||||
my $rhFileConstant = $rhFile->{&BLD_CONSTANT_GROUP};
|
my $rhFileConstant = $rhFile->{&BLD_CONSTANT_GROUP};
|
||||||
my $rhFileEnum = $rhFile->{&BLD_ENUM};
|
my $rhFileEnum = $rhFile->{&BLD_ENUM};
|
||||||
|
my $rhFileDeclare = $rhFile->{&BLD_DECLARE};
|
||||||
my $rhFileData = $rhFile->{&BLD_DATA};
|
my $rhFileData = $rhFile->{&BLD_DATA};
|
||||||
my $rhSource;
|
my $rhSource;
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ sub buildAll
|
|||||||
|
|
||||||
# Build header file
|
# Build header file
|
||||||
#-------------------------------------------------------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------------------------------------------------------
|
||||||
if (defined($rhFileEnum) || defined($rhFileConstant))
|
if (defined($rhFileEnum) || defined($rhFileConstant) || defined($rhFileDeclare))
|
||||||
{
|
{
|
||||||
my $strHeaderDefine = uc("${strPath}/${strFile}") . '_AUTO_H';
|
my $strHeaderDefine = uc("${strPath}/${strFile}") . '_AUTO_H';
|
||||||
$strHeaderDefine =~ s/\//_/g;
|
$strHeaderDefine =~ s/\//_/g;
|
||||||
@ -99,7 +100,7 @@ sub buildAll
|
|||||||
|
|
||||||
my $iExpectedValue = 0;
|
my $iExpectedValue = 0;
|
||||||
|
|
||||||
# Iterate constants
|
# Iterate enums
|
||||||
foreach my $strEnumItem (@{$rhEnum->{&BLD_LIST}})
|
foreach my $strEnumItem (@{$rhEnum->{&BLD_LIST}})
|
||||||
{
|
{
|
||||||
$strHeader .=
|
$strHeader .=
|
||||||
@ -119,6 +120,14 @@ sub buildAll
|
|||||||
"} " . $rhEnum->{&BLD_NAME} . ";\n";
|
"} " . $rhEnum->{&BLD_NAME} . ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach my $strDeclare (sort(keys(%{$rhFileDeclare})))
|
||||||
|
{
|
||||||
|
my $rhDeclare = $rhFileDeclare->{$strDeclare};
|
||||||
|
|
||||||
|
$strHeader .= "\n" . bldBanner($rhDeclare->{&BLD_SUMMARY});
|
||||||
|
$strHeader .= $rhDeclare->{&BLD_SOURCE};
|
||||||
|
}
|
||||||
|
|
||||||
$strHeader .=
|
$strHeader .=
|
||||||
"\n#endif";
|
"\n#endif";
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ use constant BLD_CONSTANT_VALUE => 'constant
|
|||||||
|
|
||||||
use constant BLD_DATA => 'data';
|
use constant BLD_DATA => 'data';
|
||||||
push @EXPORT, qw(BLD_DATA);
|
push @EXPORT, qw(BLD_DATA);
|
||||||
|
use constant BLD_DECLARE => 'declare';
|
||||||
|
push @EXPORT, qw(BLD_DECLARE);
|
||||||
use constant BLD_ENUM => 'enum';
|
use constant BLD_ENUM => 'enum';
|
||||||
push @EXPORT, qw(BLD_ENUM);
|
push @EXPORT, qw(BLD_ENUM);
|
||||||
use constant BLD_LIST => 'list';
|
use constant BLD_LIST => 'list';
|
||||||
|
136
build/lib/pgBackRestBuild/Error/Build.pm
Normal file
136
build/lib/pgBackRestBuild/Error/Build.pm
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
####################################################################################################################################
|
||||||
|
# Auto-Generate Error Mappings
|
||||||
|
####################################################################################################################################
|
||||||
|
package pgBackRestBuild::Error::Build;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings FATAL => qw(all);
|
||||||
|
use Carp qw(confess);
|
||||||
|
use English '-no_match_vars';
|
||||||
|
|
||||||
|
use Exporter qw(import);
|
||||||
|
our @EXPORT = qw();
|
||||||
|
|
||||||
|
use pgBackRestBuild::Build::Common;
|
||||||
|
use pgBackRestBuild::Error::Data;
|
||||||
|
|
||||||
|
use pgBackRest::Common::Log;
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Constants
|
||||||
|
####################################################################################################################################
|
||||||
|
use constant BLDLCL_FILE_DEFINE => 'error';
|
||||||
|
|
||||||
|
use constant BLDLCL_DATA_ERROR => '01-dataError';
|
||||||
|
use constant BLDLCL_DATA_ERROR_ARRAY => '01-dataErrorArray';
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Definitions for constants and data to build
|
||||||
|
####################################################################################################################################
|
||||||
|
my $strSummary = 'Error Type Definition';
|
||||||
|
|
||||||
|
my $rhBuild =
|
||||||
|
{
|
||||||
|
&BLD_FILE =>
|
||||||
|
{
|
||||||
|
&BLDLCL_FILE_DEFINE =>
|
||||||
|
{
|
||||||
|
&BLD_SUMMARY => $strSummary,
|
||||||
|
|
||||||
|
&BLD_DECLARE =>
|
||||||
|
{
|
||||||
|
&BLDLCL_DATA_ERROR =>
|
||||||
|
{
|
||||||
|
&BLD_SUMMARY => 'Error type declarations',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
&BLD_DATA =>
|
||||||
|
{
|
||||||
|
&BLDLCL_DATA_ERROR =>
|
||||||
|
{
|
||||||
|
&BLD_SUMMARY => 'Error type definitions',
|
||||||
|
},
|
||||||
|
|
||||||
|
&BLDLCL_DATA_ERROR_ARRAY =>
|
||||||
|
{
|
||||||
|
&BLD_SUMMARY => 'Error type array',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Build configuration constants and data
|
||||||
|
####################################################################################################################################
|
||||||
|
sub buildError
|
||||||
|
{
|
||||||
|
# Build error list
|
||||||
|
#-------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
my $rhErrorDefine = errorDefine();
|
||||||
|
|
||||||
|
# Order by id for the list that is id ordered
|
||||||
|
my $rhErrorId = {};
|
||||||
|
|
||||||
|
foreach my $strType (sort(keys(%{$rhErrorDefine})))
|
||||||
|
{
|
||||||
|
my $iCode = $rhErrorDefine->{$strType};
|
||||||
|
|
||||||
|
if (defined($rhErrorId->{$iCode}))
|
||||||
|
{
|
||||||
|
confess &log(ERROR, "error code ${iCode} is by '" . $rhErrorId->{$iCode} . "' and '${strType}'");
|
||||||
|
}
|
||||||
|
|
||||||
|
$rhErrorId->{$iCode} = $strType;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Output errors
|
||||||
|
my $strBuildSource;
|
||||||
|
|
||||||
|
foreach my $iCode (sort({sprintf("%03d", $a) cmp sprintf("%03d", $b)} keys(%{$rhErrorId})))
|
||||||
|
{
|
||||||
|
my $strType = $rhErrorId->{$iCode};
|
||||||
|
|
||||||
|
$strBuildSource .=
|
||||||
|
"ERROR_DECLARE(" . bldEnum("", $strType, true) . "Error);\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$rhBuild->{&BLD_FILE}{&BLDLCL_FILE_DEFINE}{&BLD_DECLARE}{&BLDLCL_DATA_ERROR}{&BLD_SOURCE} = $strBuildSource;
|
||||||
|
|
||||||
|
# Output error definition data
|
||||||
|
$strBuildSource = undef;
|
||||||
|
|
||||||
|
foreach my $iCode (sort({sprintf("%03d", $a) cmp sprintf("%03d", $b)} keys(%{$rhErrorId})))
|
||||||
|
{
|
||||||
|
my $strType = $rhErrorId->{$iCode};
|
||||||
|
|
||||||
|
$strBuildSource .=
|
||||||
|
"ERROR_DEFINE(" . (' ' x (3 - length($iCode))) . "${iCode}, " . bldEnum("", $strType, true) . "Error, RuntimeError);\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$rhBuild->{&BLD_FILE}{&BLDLCL_FILE_DEFINE}{&BLD_DATA}{&BLDLCL_DATA_ERROR}{&BLD_SOURCE} = $strBuildSource;
|
||||||
|
|
||||||
|
# Output error array
|
||||||
|
$strBuildSource =
|
||||||
|
"static const ErrorType *errorTypeList[] =\n" .
|
||||||
|
"{\n";
|
||||||
|
|
||||||
|
foreach my $iCode (sort({sprintf("%03d", $a) cmp sprintf("%03d", $b)} keys(%{$rhErrorId})))
|
||||||
|
{
|
||||||
|
$strBuildSource .=
|
||||||
|
" &" . bldEnum("", $rhErrorId->{$iCode}, true) . "Error,\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$strBuildSource .=
|
||||||
|
" NULL,\n" .
|
||||||
|
"};";
|
||||||
|
|
||||||
|
$rhBuild->{&BLD_FILE}{&BLDLCL_FILE_DEFINE}{&BLD_DATA}{&BLDLCL_DATA_ERROR_ARRAY}{&BLD_SOURCE} = $strBuildSource;
|
||||||
|
|
||||||
|
return $rhBuild;
|
||||||
|
}
|
||||||
|
|
||||||
|
push @EXPORT, qw(buildError);
|
||||||
|
|
||||||
|
1;
|
52
build/lib/pgBackRestBuild/Error/Data.pm
Normal file
52
build/lib/pgBackRestBuild/Error/Data.pm
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
####################################################################################################################################
|
||||||
|
# Error Definition Data
|
||||||
|
####################################################################################################################################
|
||||||
|
package pgBackRestBuild::Error::Data;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings FATAL => qw(all);
|
||||||
|
use Carp qw(confess);
|
||||||
|
|
||||||
|
use Exporter qw(import);
|
||||||
|
our @EXPORT = qw();
|
||||||
|
use Storable qw(dclone);
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Error min and max values
|
||||||
|
####################################################################################################################################
|
||||||
|
use constant ERRDEF_MIN => 25;
|
||||||
|
push @EXPORT, qw(ERRDEF_MIN);
|
||||||
|
use constant ERRDEF_MAX => 125;
|
||||||
|
push @EXPORT, qw(ERRDEF_MAX);
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Error definition data
|
||||||
|
####################################################################################################################################
|
||||||
|
my $rhErrorDefine;
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Load error definition from YAML
|
||||||
|
####################################################################################################################################
|
||||||
|
sub errorDefineLoad
|
||||||
|
{
|
||||||
|
my $strErrorYaml = shift;
|
||||||
|
|
||||||
|
require YAML;
|
||||||
|
YAML->import(qw(Dump Load));
|
||||||
|
|
||||||
|
$rhErrorDefine = Load($strErrorYaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
push @EXPORT, qw(errorDefineLoad);
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Get error definition
|
||||||
|
####################################################################################################################################
|
||||||
|
sub errorDefine
|
||||||
|
{
|
||||||
|
return dclone($rhErrorDefine);
|
||||||
|
}
|
||||||
|
|
||||||
|
push @EXPORT, qw(errorDefine);
|
||||||
|
|
||||||
|
1;
|
@ -132,6 +132,10 @@
|
|||||||
<p>Improve <code>error</code> module. Add functions to convert error codes to C errors and handle system errors.</p>
|
<p>Improve <code>error</code> module. Add functions to convert error codes to C errors and handle system errors.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
|
||||||
|
<release-item>
|
||||||
|
<p>Create a master list of errors in <file>build/error.yaml</file>. The C and Perl errors lists are created automatically by <code>Build.pm</code> so they stay up to date.</p>
|
||||||
|
</release-item>
|
||||||
|
|
||||||
<release-item>
|
<release-item>
|
||||||
<p>Move lock release later in exitSafe() to reduce the chance of a new process starting and acquiring a lock before the old process has exited.</p>
|
<p>Move lock release later in exitSafe() to reduce the chance of a new process starting and acquiring a lock before the old process has exited.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
|
@ -12,163 +12,12 @@ use Scalar::Util qw(blessed);
|
|||||||
use Exporter qw(import);
|
use Exporter qw(import);
|
||||||
our @EXPORT = qw();
|
our @EXPORT = qw();
|
||||||
|
|
||||||
####################################################################################################################################
|
use pgBackRest::Common::ExceptionAuto;
|
||||||
# Exception codes
|
|
||||||
####################################################################################################################################
|
|
||||||
use constant ERROR_MINIMUM => 25;
|
|
||||||
push @EXPORT, qw(ERROR_MINIMUM);
|
|
||||||
use constant ERROR_MAXIMUM => 125;
|
|
||||||
push @EXPORT, qw(ERROR_MAXIMUM);
|
|
||||||
|
|
||||||
use constant ERROR_ASSERT => ERROR_MINIMUM;
|
####################################################################################################################################
|
||||||
push @EXPORT, qw(ERROR_ASSERT);
|
# Export error constants
|
||||||
use constant ERROR_CHECKSUM => ERROR_MINIMUM + 1;
|
####################################################################################################################################
|
||||||
push @EXPORT, qw(ERROR_CHECKSUM);
|
push(@EXPORT, @pgBackRest::Common::ExceptionAuto::EXPORT);
|
||||||
use constant ERROR_CONFIG => ERROR_MINIMUM + 2;
|
|
||||||
push @EXPORT, qw(ERROR_CONFIG);
|
|
||||||
use constant ERROR_FILE_INVALID => ERROR_MINIMUM + 3;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_INVALID);
|
|
||||||
use constant ERROR_FORMAT => ERROR_MINIMUM + 4;
|
|
||||||
push @EXPORT, qw(ERROR_FORMAT);
|
|
||||||
use constant ERROR_COMMAND_REQUIRED => ERROR_MINIMUM + 5;
|
|
||||||
push @EXPORT, qw(ERROR_COMMAND_REQUIRED);
|
|
||||||
use constant ERROR_OPTION_INVALID => ERROR_MINIMUM + 6;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_INVALID);
|
|
||||||
use constant ERROR_OPTION_INVALID_VALUE => ERROR_MINIMUM + 7;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_INVALID_VALUE);
|
|
||||||
use constant ERROR_OPTION_INVALID_RANGE => ERROR_MINIMUM + 8;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_INVALID_RANGE);
|
|
||||||
use constant ERROR_OPTION_INVALID_PAIR => ERROR_MINIMUM + 9;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_INVALID_PAIR);
|
|
||||||
use constant ERROR_OPTION_DUPLICATE_KEY => ERROR_MINIMUM + 10;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_DUPLICATE_KEY);
|
|
||||||
use constant ERROR_OPTION_NEGATE => ERROR_MINIMUM + 11;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_NEGATE);
|
|
||||||
use constant ERROR_OPTION_REQUIRED => ERROR_MINIMUM + 12;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_REQUIRED);
|
|
||||||
use constant ERROR_POSTMASTER_RUNNING => ERROR_MINIMUM + 13;
|
|
||||||
push @EXPORT, qw(ERROR_POSTMASTER_RUNNING);
|
|
||||||
use constant ERROR_PROTOCOL => ERROR_MINIMUM + 14;
|
|
||||||
push @EXPORT, qw(ERROR_PROTOCOL);
|
|
||||||
use constant ERROR_PATH_NOT_EMPTY => ERROR_MINIMUM + 15;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_NOT_EMPTY);
|
|
||||||
use constant ERROR_FILE_OPEN => ERROR_MINIMUM + 16;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_OPEN);
|
|
||||||
use constant ERROR_FILE_READ => ERROR_MINIMUM + 17;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_READ);
|
|
||||||
use constant ERROR_PARAM_REQUIRED => ERROR_MINIMUM + 18;
|
|
||||||
push @EXPORT, qw(ERROR_PARAM_REQUIRED);
|
|
||||||
use constant ERROR_ARCHIVE_MISMATCH => ERROR_MINIMUM + 19;
|
|
||||||
push @EXPORT, qw(ERROR_ARCHIVE_MISMATCH);
|
|
||||||
use constant ERROR_ARCHIVE_DUPLICATE => ERROR_MINIMUM + 20;
|
|
||||||
push @EXPORT, qw(ERROR_ARCHIVE_DUPLICATE);
|
|
||||||
use constant ERROR_VERSION_NOT_SUPPORTED => ERROR_MINIMUM + 21;
|
|
||||||
push @EXPORT, qw(ERROR_VERSION_NOT_SUPPORTED);
|
|
||||||
use constant ERROR_PATH_CREATE => ERROR_MINIMUM + 22;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_CREATE);
|
|
||||||
use constant ERROR_COMMAND_INVALID => ERROR_MINIMUM + 23;
|
|
||||||
push @EXPORT, qw(ERROR_COMMAND_INVALID);
|
|
||||||
use constant ERROR_HOST_CONNECT => ERROR_MINIMUM + 24;
|
|
||||||
push @EXPORT, qw(ERROR_HOST_CONNECT);
|
|
||||||
use constant ERROR_LOCK_ACQUIRE => ERROR_MINIMUM + 25;
|
|
||||||
push @EXPORT, qw(ERROR_LOCK_ACQUIRE);
|
|
||||||
use constant ERROR_BACKUP_MISMATCH => ERROR_MINIMUM + 26;
|
|
||||||
push @EXPORT, qw(ERROR_BACKUP_MISMATCH);
|
|
||||||
use constant ERROR_FILE_SYNC => ERROR_MINIMUM + 27;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_SYNC);
|
|
||||||
use constant ERROR_PATH_OPEN => ERROR_MINIMUM + 28;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_OPEN);
|
|
||||||
use constant ERROR_PATH_SYNC => ERROR_MINIMUM + 29;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_SYNC);
|
|
||||||
use constant ERROR_FILE_MISSING => ERROR_MINIMUM + 30;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_MISSING);
|
|
||||||
use constant ERROR_DB_CONNECT => ERROR_MINIMUM + 31;
|
|
||||||
push @EXPORT, qw(ERROR_DB_CONNECT);
|
|
||||||
use constant ERROR_DB_QUERY => ERROR_MINIMUM + 32;
|
|
||||||
push @EXPORT, qw(ERROR_DB_QUERY);
|
|
||||||
use constant ERROR_DB_MISMATCH => ERROR_MINIMUM + 33;
|
|
||||||
push @EXPORT, qw(ERROR_DB_MISMATCH);
|
|
||||||
use constant ERROR_DB_TIMEOUT => ERROR_MINIMUM + 34;
|
|
||||||
push @EXPORT, qw(ERROR_DB_TIMEOUT);
|
|
||||||
use constant ERROR_FILE_REMOVE => ERROR_MINIMUM + 35;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_REMOVE);
|
|
||||||
use constant ERROR_PATH_REMOVE => ERROR_MINIMUM + 36;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_REMOVE);
|
|
||||||
use constant ERROR_STOP => ERROR_MINIMUM + 37;
|
|
||||||
push @EXPORT, qw(ERROR_STOP);
|
|
||||||
use constant ERROR_TERM => ERROR_MINIMUM + 38;
|
|
||||||
push @EXPORT, qw(ERROR_TERM);
|
|
||||||
use constant ERROR_FILE_WRITE => ERROR_MINIMUM + 39;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_WRITE);
|
|
||||||
use constant ERROR_PROTOCOL_TIMEOUT => ERROR_MINIMUM + 41;
|
|
||||||
push @EXPORT, qw(ERROR_PROTOCOL_TIMEOUT);
|
|
||||||
use constant ERROR_FEATURE_NOT_SUPPORTED => ERROR_MINIMUM + 42;
|
|
||||||
push @EXPORT, qw(ERROR_FEATURE_NOT_SUPPORTED);
|
|
||||||
use constant ERROR_ARCHIVE_COMMAND_INVALID => ERROR_MINIMUM + 43;
|
|
||||||
push @EXPORT, qw(ERROR_ARCHIVE_COMMAND_INVALID);
|
|
||||||
use constant ERROR_LINK_EXPECTED => ERROR_MINIMUM + 44;
|
|
||||||
push @EXPORT, qw(ERROR_LINK_EXPECTED);
|
|
||||||
use constant ERROR_LINK_DESTINATION => ERROR_MINIMUM + 45;
|
|
||||||
push @EXPORT, qw(ERROR_LINK_DESTINATION);
|
|
||||||
use constant ERROR_TABLESPACE_IN_PGDATA => ERROR_MINIMUM + 46;
|
|
||||||
push @EXPORT, qw(ERROR_TABLESPACE_IN_PGDATA);
|
|
||||||
use constant ERROR_HOST_INVALID => ERROR_MINIMUM + 47;
|
|
||||||
push @EXPORT, qw(ERROR_HOST_INVALID);
|
|
||||||
use constant ERROR_PATH_MISSING => ERROR_MINIMUM + 48;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_MISSING);
|
|
||||||
use constant ERROR_FILE_MOVE => ERROR_MINIMUM + 49;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_MOVE);
|
|
||||||
use constant ERROR_BACKUP_SET_INVALID => ERROR_MINIMUM + 50;
|
|
||||||
push @EXPORT, qw(ERROR_BACKUP_SET_INVALID);
|
|
||||||
use constant ERROR_TABLESPACE_MAP => ERROR_MINIMUM + 51;
|
|
||||||
push @EXPORT, qw(ERROR_TABLESPACE_MAP);
|
|
||||||
use constant ERROR_PATH_TYPE => ERROR_MINIMUM + 52;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_TYPE);
|
|
||||||
use constant ERROR_LINK_MAP => ERROR_MINIMUM + 53;
|
|
||||||
push @EXPORT, qw(ERROR_LINK_MAP);
|
|
||||||
use constant ERROR_FILE_CLOSE => ERROR_MINIMUM + 54;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_CLOSE);
|
|
||||||
use constant ERROR_DB_MISSING => ERROR_MINIMUM + 55;
|
|
||||||
push @EXPORT, qw(ERROR_DB_MISSING);
|
|
||||||
use constant ERROR_DB_INVALID => ERROR_MINIMUM + 56;
|
|
||||||
push @EXPORT, qw(ERROR_DB_INVALID);
|
|
||||||
use constant ERROR_ARCHIVE_TIMEOUT => ERROR_MINIMUM + 57;
|
|
||||||
push @EXPORT, qw(ERROR_ARCHIVE_TIMEOUT);
|
|
||||||
use constant ERROR_FILE_MODE => ERROR_MINIMUM + 58;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_MODE);
|
|
||||||
use constant ERROR_OPTION_MULTIPLE_VALUE => ERROR_MINIMUM + 59;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_MULTIPLE_VALUE);
|
|
||||||
use constant ERROR_PROTOCOL_OUTPUT_REQUIRED => ERROR_MINIMUM + 60;
|
|
||||||
push @EXPORT, qw(ERROR_PROTOCOL_OUTPUT_REQUIRED);
|
|
||||||
use constant ERROR_LINK_OPEN => ERROR_MINIMUM + 61;
|
|
||||||
push @EXPORT, qw(ERROR_LINK_OPEN);
|
|
||||||
use constant ERROR_ARCHIVE_DISABLED => ERROR_MINIMUM + 62;
|
|
||||||
push @EXPORT, qw(ERROR_ARCHIVE_DISABLED);
|
|
||||||
use constant ERROR_FILE_OWNER => ERROR_MINIMUM + 63;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_OWNER);
|
|
||||||
use constant ERROR_USER_MISSING => ERROR_MINIMUM + 64;
|
|
||||||
push @EXPORT, qw(ERROR_USER_MISSING);
|
|
||||||
use constant ERROR_OPTION_COMMAND => ERROR_MINIMUM + 65;
|
|
||||||
push @EXPORT, qw(ERROR_OPTION_COMMAND);
|
|
||||||
use constant ERROR_GROUP_MISSING => ERROR_MINIMUM + 66;
|
|
||||||
push @EXPORT, qw(ERROR_GROUP_MISSING);
|
|
||||||
use constant ERROR_PATH_EXISTS => ERROR_MINIMUM + 67;
|
|
||||||
push @EXPORT, qw(ERROR_PATH_EXISTS);
|
|
||||||
use constant ERROR_FILE_EXISTS => ERROR_MINIMUM + 68;
|
|
||||||
push @EXPORT, qw(ERROR_FILE_EXISTS);
|
|
||||||
use constant ERROR_MEMORY => ERROR_MINIMUM + 69; # Thrown by C library
|
|
||||||
push @EXPORT, qw(ERROR_MEMORY);
|
|
||||||
use constant ERROR_CIPHER => ERROR_MINIMUM + 70;
|
|
||||||
push @EXPORT, qw(ERROR_CIPHER);
|
|
||||||
use constant ERROR_PARAM_INVALID => ERROR_MINIMUM + 71;
|
|
||||||
push @EXPORT, qw(ERROR_PARAM_INVALID);
|
|
||||||
|
|
||||||
use constant ERROR_INVALID_VALUE => ERROR_MAXIMUM - 2;
|
|
||||||
push @EXPORT, qw(ERROR_INVALID_VALUE);
|
|
||||||
use constant ERROR_UNHANDLED => ERROR_MAXIMUM - 1;
|
|
||||||
push @EXPORT, qw(ERROR_UNHANDLED);
|
|
||||||
use constant ERROR_UNKNOWN => ERROR_MAXIMUM;
|
|
||||||
push @EXPORT, qw(ERROR_UNKNOWN);
|
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# CONSTRUCTOR
|
# CONSTRUCTOR
|
||||||
@ -184,7 +33,7 @@ sub new
|
|||||||
|
|
||||||
if ($iCode < ERROR_MINIMUM || $iCode > ERROR_MAXIMUM)
|
if ($iCode < ERROR_MINIMUM || $iCode > ERROR_MAXIMUM)
|
||||||
{
|
{
|
||||||
$iCode = ERROR_INVALID_VALUE;
|
$iCode = ERROR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the class hash
|
# Create the class hash
|
||||||
|
173
lib/pgBackRest/Common/ExceptionAuto.pm
Normal file
173
lib/pgBackRest/Common/ExceptionAuto.pm
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
####################################################################################################################################
|
||||||
|
# COMMON EXCEPTION AUTO MODULE
|
||||||
|
#
|
||||||
|
# Automatically generated by Build.pm -- do not modify directly.
|
||||||
|
####################################################################################################################################
|
||||||
|
package pgBackRest::Common::ExceptionAuto;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings FATAL => qw(all);
|
||||||
|
|
||||||
|
use Exporter qw(import);
|
||||||
|
our @EXPORT = qw();
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Error Definitions
|
||||||
|
####################################################################################################################################
|
||||||
|
use constant ERROR_MINIMUM => 25;
|
||||||
|
push @EXPORT, qw(ERROR_MINIMUM);
|
||||||
|
use constant ERROR_MAXIMUM => 125;
|
||||||
|
push @EXPORT, qw(ERROR_MAXIMUM);
|
||||||
|
|
||||||
|
use constant ERROR_ASSERT => 25;
|
||||||
|
push @EXPORT, qw(ERROR_ASSERT);
|
||||||
|
use constant ERROR_CHECKSUM => 26;
|
||||||
|
push @EXPORT, qw(ERROR_CHECKSUM);
|
||||||
|
use constant ERROR_CONFIG => 27;
|
||||||
|
push @EXPORT, qw(ERROR_CONFIG);
|
||||||
|
use constant ERROR_FILE_INVALID => 28;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_INVALID);
|
||||||
|
use constant ERROR_FORMAT => 29;
|
||||||
|
push @EXPORT, qw(ERROR_FORMAT);
|
||||||
|
use constant ERROR_COMMAND_REQUIRED => 30;
|
||||||
|
push @EXPORT, qw(ERROR_COMMAND_REQUIRED);
|
||||||
|
use constant ERROR_OPTION_INVALID => 31;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_INVALID);
|
||||||
|
use constant ERROR_OPTION_INVALID_VALUE => 32;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_INVALID_VALUE);
|
||||||
|
use constant ERROR_OPTION_INVALID_RANGE => 33;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_INVALID_RANGE);
|
||||||
|
use constant ERROR_OPTION_INVALID_PAIR => 34;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_INVALID_PAIR);
|
||||||
|
use constant ERROR_OPTION_DUPLICATE_KEY => 35;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_DUPLICATE_KEY);
|
||||||
|
use constant ERROR_OPTION_NEGATE => 36;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_NEGATE);
|
||||||
|
use constant ERROR_OPTION_REQUIRED => 37;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_REQUIRED);
|
||||||
|
use constant ERROR_POSTMASTER_RUNNING => 38;
|
||||||
|
push @EXPORT, qw(ERROR_POSTMASTER_RUNNING);
|
||||||
|
use constant ERROR_PROTOCOL => 39;
|
||||||
|
push @EXPORT, qw(ERROR_PROTOCOL);
|
||||||
|
use constant ERROR_PATH_NOT_EMPTY => 40;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_NOT_EMPTY);
|
||||||
|
use constant ERROR_FILE_OPEN => 41;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_OPEN);
|
||||||
|
use constant ERROR_FILE_READ => 42;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_READ);
|
||||||
|
use constant ERROR_PARAM_REQUIRED => 43;
|
||||||
|
push @EXPORT, qw(ERROR_PARAM_REQUIRED);
|
||||||
|
use constant ERROR_ARCHIVE_MISMATCH => 44;
|
||||||
|
push @EXPORT, qw(ERROR_ARCHIVE_MISMATCH);
|
||||||
|
use constant ERROR_ARCHIVE_DUPLICATE => 45;
|
||||||
|
push @EXPORT, qw(ERROR_ARCHIVE_DUPLICATE);
|
||||||
|
use constant ERROR_VERSION_NOT_SUPPORTED => 46;
|
||||||
|
push @EXPORT, qw(ERROR_VERSION_NOT_SUPPORTED);
|
||||||
|
use constant ERROR_PATH_CREATE => 47;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_CREATE);
|
||||||
|
use constant ERROR_COMMAND_INVALID => 48;
|
||||||
|
push @EXPORT, qw(ERROR_COMMAND_INVALID);
|
||||||
|
use constant ERROR_HOST_CONNECT => 49;
|
||||||
|
push @EXPORT, qw(ERROR_HOST_CONNECT);
|
||||||
|
use constant ERROR_LOCK_ACQUIRE => 50;
|
||||||
|
push @EXPORT, qw(ERROR_LOCK_ACQUIRE);
|
||||||
|
use constant ERROR_BACKUP_MISMATCH => 51;
|
||||||
|
push @EXPORT, qw(ERROR_BACKUP_MISMATCH);
|
||||||
|
use constant ERROR_FILE_SYNC => 52;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_SYNC);
|
||||||
|
use constant ERROR_PATH_OPEN => 53;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_OPEN);
|
||||||
|
use constant ERROR_PATH_SYNC => 54;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_SYNC);
|
||||||
|
use constant ERROR_FILE_MISSING => 55;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_MISSING);
|
||||||
|
use constant ERROR_DB_CONNECT => 56;
|
||||||
|
push @EXPORT, qw(ERROR_DB_CONNECT);
|
||||||
|
use constant ERROR_DB_QUERY => 57;
|
||||||
|
push @EXPORT, qw(ERROR_DB_QUERY);
|
||||||
|
use constant ERROR_DB_MISMATCH => 58;
|
||||||
|
push @EXPORT, qw(ERROR_DB_MISMATCH);
|
||||||
|
use constant ERROR_DB_TIMEOUT => 59;
|
||||||
|
push @EXPORT, qw(ERROR_DB_TIMEOUT);
|
||||||
|
use constant ERROR_FILE_REMOVE => 60;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_REMOVE);
|
||||||
|
use constant ERROR_PATH_REMOVE => 61;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_REMOVE);
|
||||||
|
use constant ERROR_STOP => 62;
|
||||||
|
push @EXPORT, qw(ERROR_STOP);
|
||||||
|
use constant ERROR_TERM => 63;
|
||||||
|
push @EXPORT, qw(ERROR_TERM);
|
||||||
|
use constant ERROR_FILE_WRITE => 64;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_WRITE);
|
||||||
|
use constant ERROR_PROTOCOL_TIMEOUT => 66;
|
||||||
|
push @EXPORT, qw(ERROR_PROTOCOL_TIMEOUT);
|
||||||
|
use constant ERROR_FEATURE_NOT_SUPPORTED => 67;
|
||||||
|
push @EXPORT, qw(ERROR_FEATURE_NOT_SUPPORTED);
|
||||||
|
use constant ERROR_ARCHIVE_COMMAND_INVALID => 68;
|
||||||
|
push @EXPORT, qw(ERROR_ARCHIVE_COMMAND_INVALID);
|
||||||
|
use constant ERROR_LINK_EXPECTED => 69;
|
||||||
|
push @EXPORT, qw(ERROR_LINK_EXPECTED);
|
||||||
|
use constant ERROR_LINK_DESTINATION => 70;
|
||||||
|
push @EXPORT, qw(ERROR_LINK_DESTINATION);
|
||||||
|
use constant ERROR_TABLESPACE_IN_PGDATA => 71;
|
||||||
|
push @EXPORT, qw(ERROR_TABLESPACE_IN_PGDATA);
|
||||||
|
use constant ERROR_HOST_INVALID => 72;
|
||||||
|
push @EXPORT, qw(ERROR_HOST_INVALID);
|
||||||
|
use constant ERROR_PATH_MISSING => 73;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_MISSING);
|
||||||
|
use constant ERROR_FILE_MOVE => 74;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_MOVE);
|
||||||
|
use constant ERROR_BACKUP_SET_INVALID => 75;
|
||||||
|
push @EXPORT, qw(ERROR_BACKUP_SET_INVALID);
|
||||||
|
use constant ERROR_TABLESPACE_MAP => 76;
|
||||||
|
push @EXPORT, qw(ERROR_TABLESPACE_MAP);
|
||||||
|
use constant ERROR_PATH_TYPE => 77;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_TYPE);
|
||||||
|
use constant ERROR_LINK_MAP => 78;
|
||||||
|
push @EXPORT, qw(ERROR_LINK_MAP);
|
||||||
|
use constant ERROR_FILE_CLOSE => 79;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_CLOSE);
|
||||||
|
use constant ERROR_DB_MISSING => 80;
|
||||||
|
push @EXPORT, qw(ERROR_DB_MISSING);
|
||||||
|
use constant ERROR_DB_INVALID => 81;
|
||||||
|
push @EXPORT, qw(ERROR_DB_INVALID);
|
||||||
|
use constant ERROR_ARCHIVE_TIMEOUT => 82;
|
||||||
|
push @EXPORT, qw(ERROR_ARCHIVE_TIMEOUT);
|
||||||
|
use constant ERROR_FILE_MODE => 83;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_MODE);
|
||||||
|
use constant ERROR_OPTION_MULTIPLE_VALUE => 84;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_MULTIPLE_VALUE);
|
||||||
|
use constant ERROR_PROTOCOL_OUTPUT_REQUIRED => 85;
|
||||||
|
push @EXPORT, qw(ERROR_PROTOCOL_OUTPUT_REQUIRED);
|
||||||
|
use constant ERROR_LINK_OPEN => 86;
|
||||||
|
push @EXPORT, qw(ERROR_LINK_OPEN);
|
||||||
|
use constant ERROR_ARCHIVE_DISABLED => 87;
|
||||||
|
push @EXPORT, qw(ERROR_ARCHIVE_DISABLED);
|
||||||
|
use constant ERROR_FILE_OWNER => 88;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_OWNER);
|
||||||
|
use constant ERROR_USER_MISSING => 89;
|
||||||
|
push @EXPORT, qw(ERROR_USER_MISSING);
|
||||||
|
use constant ERROR_OPTION_COMMAND => 90;
|
||||||
|
push @EXPORT, qw(ERROR_OPTION_COMMAND);
|
||||||
|
use constant ERROR_GROUP_MISSING => 91;
|
||||||
|
push @EXPORT, qw(ERROR_GROUP_MISSING);
|
||||||
|
use constant ERROR_PATH_EXISTS => 92;
|
||||||
|
push @EXPORT, qw(ERROR_PATH_EXISTS);
|
||||||
|
use constant ERROR_FILE_EXISTS => 93;
|
||||||
|
push @EXPORT, qw(ERROR_FILE_EXISTS);
|
||||||
|
use constant ERROR_MEMORY => 94;
|
||||||
|
push @EXPORT, qw(ERROR_MEMORY);
|
||||||
|
use constant ERROR_CIPHER => 95;
|
||||||
|
push @EXPORT, qw(ERROR_CIPHER);
|
||||||
|
use constant ERROR_PARAM_INVALID => 96;
|
||||||
|
push @EXPORT, qw(ERROR_PARAM_INVALID);
|
||||||
|
use constant ERROR_RUNTIME => 122;
|
||||||
|
push @EXPORT, qw(ERROR_RUNTIME);
|
||||||
|
use constant ERROR_INVALID => 123;
|
||||||
|
push @EXPORT, qw(ERROR_INVALID);
|
||||||
|
use constant ERROR_UNHANDLED => 124;
|
||||||
|
push @EXPORT, qw(ERROR_UNHANDLED);
|
||||||
|
use constant ERROR_UNKNOWN => 125;
|
||||||
|
push @EXPORT, qw(ERROR_UNKNOWN);
|
||||||
|
|
||||||
|
1;
|
@ -80,7 +80,6 @@ my @stryCFile =
|
|||||||
'common/encode.c',
|
'common/encode.c',
|
||||||
'common/encode/base64.c',
|
'common/encode/base64.c',
|
||||||
'common/error.c',
|
'common/error.c',
|
||||||
'common/errorType.c',
|
|
||||||
'common/ini.c',
|
'common/ini.c',
|
||||||
'common/log.c',
|
'common/log.c',
|
||||||
'common/memContext.c',
|
'common/memContext.c',
|
||||||
|
@ -26,6 +26,7 @@ use pgBackRest::Version;
|
|||||||
|
|
||||||
use pgBackRestBuild::Build;
|
use pgBackRestBuild::Build;
|
||||||
use pgBackRestBuild::Build::Common;
|
use pgBackRestBuild::Build::Common;
|
||||||
|
use pgBackRestBuild::Error::Data;
|
||||||
|
|
||||||
use pgBackRestLibC::Config::Build;
|
use pgBackRestLibC::Config::Build;
|
||||||
use pgBackRestLibC::Config::BuildDefine;
|
use pgBackRestLibC::Config::BuildDefine;
|
||||||
@ -314,6 +315,59 @@ sub buildXsAll
|
|||||||
{
|
{
|
||||||
$oStorage->put($strLibFile, $strContent);
|
$oStorage->put($strLibFile, $strContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Build error file
|
||||||
|
#-------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
my $rhErrorDefine = errorDefine();
|
||||||
|
|
||||||
|
# Order by id for the list that is id ordered
|
||||||
|
my $rhErrorId = {};
|
||||||
|
|
||||||
|
foreach my $strType (sort(keys(%{$rhErrorDefine})))
|
||||||
|
{
|
||||||
|
my $iCode = $rhErrorDefine->{$strType};
|
||||||
|
$rhErrorId->{$iCode} = $strType;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Output errors
|
||||||
|
$strContent =
|
||||||
|
('#' x 132) . "\n" .
|
||||||
|
"# COMMON EXCEPTION AUTO MODULE\n" .
|
||||||
|
"# \n" .
|
||||||
|
'# ' . bldAutoWarning('Build.pm') . "\n" .
|
||||||
|
('#' x 132) . "\n" .
|
||||||
|
"package pgBackRest::Common::ExceptionAuto;\n" .
|
||||||
|
"\n" .
|
||||||
|
"use strict;\n" .
|
||||||
|
"use warnings FATAL => qw(all);\n" .
|
||||||
|
"\n" .
|
||||||
|
"use Exporter qw(import);\n" .
|
||||||
|
" our \@EXPORT = qw();\n" .
|
||||||
|
"\n" .
|
||||||
|
('#' x 132) . "\n" .
|
||||||
|
"# Error Definitions\n" .
|
||||||
|
('#' x 132) . "\n" .
|
||||||
|
"use constant ERROR_MINIMUM => " . ERRDEF_MIN . ";\n" .
|
||||||
|
"push \@EXPORT, qw(ERROR_MINIMUM);\n" .
|
||||||
|
"use constant ERROR_MAXIMUM => " . ERRDEF_MAX . ";\n" .
|
||||||
|
"push \@EXPORT, qw(ERROR_MAXIMUM);\n" .
|
||||||
|
"\n";
|
||||||
|
|
||||||
|
foreach my $iCode (sort({sprintf("%03d", $a) cmp sprintf("%03d", $b)} keys(%{$rhErrorId})))
|
||||||
|
{
|
||||||
|
my $strType = "ERROR_" . uc($rhErrorId->{$iCode});
|
||||||
|
$strType =~ s/\-/\_/g;
|
||||||
|
|
||||||
|
$strContent .=
|
||||||
|
"use constant ${strType}" . (' ' x (54 - length($strType))) . " => $iCode;\n" .
|
||||||
|
"push \@EXPORT, qw(${strType});\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
$strContent .=
|
||||||
|
"\n" .
|
||||||
|
"1;\n";
|
||||||
|
|
||||||
|
$oStorage->put('../lib/' . BACKREST_NAME . '/Common/ExceptionAuto.pm', $strContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
push @EXPORT, qw(buildXsAll);
|
push @EXPORT, qw(buildXsAll);
|
||||||
|
@ -7,7 +7,6 @@ pgbackrest: \
|
|||||||
command/help/help.o \
|
command/help/help.o \
|
||||||
command/command.o \
|
command/command.o \
|
||||||
common/error.o \
|
common/error.o \
|
||||||
common/errorType.o \
|
|
||||||
common/exit.o \
|
common/exit.o \
|
||||||
common/ini.o \
|
common/ini.o \
|
||||||
common/log.o \
|
common/log.o \
|
||||||
@ -35,7 +34,6 @@ pgbackrest: \
|
|||||||
command/help/help.o \
|
command/help/help.o \
|
||||||
command/command.o \
|
command/command.o \
|
||||||
common/error.o \
|
common/error.o \
|
||||||
common/errorType.o \
|
|
||||||
common/exit.o \
|
common/exit.o \
|
||||||
common/ini.o \
|
common/ini.o \
|
||||||
common/log.o \
|
common/log.o \
|
||||||
|
@ -6,7 +6,6 @@ Block Cipher
|
|||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
||||||
#include "common/errorType.h"
|
|
||||||
#include "common/memContext.h"
|
#include "common/memContext.h"
|
||||||
#include "cipher/block.h"
|
#include "cipher/block.h"
|
||||||
#include "cipher/random.h"
|
#include "cipher/random.h"
|
||||||
|
167
src/common/error.auto.c
Normal file
167
src/common/error.auto.c
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error Type Definition
|
||||||
|
|
||||||
|
Automatically generated by Build.pm -- do not modify directly.
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error type definitions
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
ERROR_DEFINE( 25, AssertError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 26, ChecksumError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 27, ConfigError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 28, FileInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 29, FormatError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 30, CommandRequiredError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 31, OptionInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 32, OptionInvalidValueError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 33, OptionInvalidRangeError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 34, OptionInvalidPairError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 35, OptionDuplicateKeyError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 36, OptionNegateError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 37, OptionRequiredError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 38, PostmasterRunningError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 39, ProtocolError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 40, PathNotEmptyError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 41, FileOpenError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 42, FileReadError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 43, ParamRequiredError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 44, ArchiveMismatchError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 45, ArchiveDuplicateError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 46, VersionNotSupportedError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 47, PathCreateError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 48, CommandInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 49, HostConnectError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 50, LockAcquireError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 51, BackupMismatchError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 52, FileSyncError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 53, PathOpenError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 54, PathSyncError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 55, FileMissingError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 56, DbConnectError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 57, DbQueryError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 58, DbMismatchError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 59, DbTimeoutError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 60, FileRemoveError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 61, PathRemoveError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 62, StopError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 63, TermError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 64, FileWriteError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 66, ProtocolTimeoutError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 67, FeatureNotSupportedError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 68, ArchiveCommandInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 69, LinkExpectedError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 70, LinkDestinationError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 71, TablespaceInPgdataError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 72, HostInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 73, PathMissingError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 74, FileMoveError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 75, BackupSetInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 76, TablespaceMapError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 77, PathTypeError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 78, LinkMapError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 79, FileCloseError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 80, DbMissingError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 81, DbInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 82, ArchiveTimeoutError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 83, FileModeError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 84, OptionMultipleValueError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 85, ProtocolOutputRequiredError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 86, LinkOpenError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 87, ArchiveDisabledError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 88, FileOwnerError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 89, UserMissingError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 90, OptionCommandError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 91, GroupMissingError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 92, PathExistsError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 93, FileExistsError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 94, MemoryError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 95, CipherError, RuntimeError);
|
||||||
|
ERROR_DEFINE( 96, ParamInvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE(122, RuntimeError, RuntimeError);
|
||||||
|
ERROR_DEFINE(123, InvalidError, RuntimeError);
|
||||||
|
ERROR_DEFINE(124, UnhandledError, RuntimeError);
|
||||||
|
ERROR_DEFINE(125, UnknownError, RuntimeError);
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error type array
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
static const ErrorType *errorTypeList[] =
|
||||||
|
{
|
||||||
|
&AssertError,
|
||||||
|
&ChecksumError,
|
||||||
|
&ConfigError,
|
||||||
|
&FileInvalidError,
|
||||||
|
&FormatError,
|
||||||
|
&CommandRequiredError,
|
||||||
|
&OptionInvalidError,
|
||||||
|
&OptionInvalidValueError,
|
||||||
|
&OptionInvalidRangeError,
|
||||||
|
&OptionInvalidPairError,
|
||||||
|
&OptionDuplicateKeyError,
|
||||||
|
&OptionNegateError,
|
||||||
|
&OptionRequiredError,
|
||||||
|
&PostmasterRunningError,
|
||||||
|
&ProtocolError,
|
||||||
|
&PathNotEmptyError,
|
||||||
|
&FileOpenError,
|
||||||
|
&FileReadError,
|
||||||
|
&ParamRequiredError,
|
||||||
|
&ArchiveMismatchError,
|
||||||
|
&ArchiveDuplicateError,
|
||||||
|
&VersionNotSupportedError,
|
||||||
|
&PathCreateError,
|
||||||
|
&CommandInvalidError,
|
||||||
|
&HostConnectError,
|
||||||
|
&LockAcquireError,
|
||||||
|
&BackupMismatchError,
|
||||||
|
&FileSyncError,
|
||||||
|
&PathOpenError,
|
||||||
|
&PathSyncError,
|
||||||
|
&FileMissingError,
|
||||||
|
&DbConnectError,
|
||||||
|
&DbQueryError,
|
||||||
|
&DbMismatchError,
|
||||||
|
&DbTimeoutError,
|
||||||
|
&FileRemoveError,
|
||||||
|
&PathRemoveError,
|
||||||
|
&StopError,
|
||||||
|
&TermError,
|
||||||
|
&FileWriteError,
|
||||||
|
&ProtocolTimeoutError,
|
||||||
|
&FeatureNotSupportedError,
|
||||||
|
&ArchiveCommandInvalidError,
|
||||||
|
&LinkExpectedError,
|
||||||
|
&LinkDestinationError,
|
||||||
|
&TablespaceInPgdataError,
|
||||||
|
&HostInvalidError,
|
||||||
|
&PathMissingError,
|
||||||
|
&FileMoveError,
|
||||||
|
&BackupSetInvalidError,
|
||||||
|
&TablespaceMapError,
|
||||||
|
&PathTypeError,
|
||||||
|
&LinkMapError,
|
||||||
|
&FileCloseError,
|
||||||
|
&DbMissingError,
|
||||||
|
&DbInvalidError,
|
||||||
|
&ArchiveTimeoutError,
|
||||||
|
&FileModeError,
|
||||||
|
&OptionMultipleValueError,
|
||||||
|
&ProtocolOutputRequiredError,
|
||||||
|
&LinkOpenError,
|
||||||
|
&ArchiveDisabledError,
|
||||||
|
&FileOwnerError,
|
||||||
|
&UserMissingError,
|
||||||
|
&OptionCommandError,
|
||||||
|
&GroupMissingError,
|
||||||
|
&PathExistsError,
|
||||||
|
&FileExistsError,
|
||||||
|
&MemoryError,
|
||||||
|
&CipherError,
|
||||||
|
&ParamInvalidError,
|
||||||
|
&RuntimeError,
|
||||||
|
&InvalidError,
|
||||||
|
&UnhandledError,
|
||||||
|
&UnknownError,
|
||||||
|
NULL,
|
||||||
|
};
|
88
src/common/error.auto.h
Normal file
88
src/common/error.auto.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error Type Definition
|
||||||
|
|
||||||
|
Automatically generated by Build.pm -- do not modify directly.
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
#ifndef COMMON_ERROR_AUTO_H
|
||||||
|
#define COMMON_ERROR_AUTO_H
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error type declarations
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
ERROR_DECLARE(AssertError);
|
||||||
|
ERROR_DECLARE(ChecksumError);
|
||||||
|
ERROR_DECLARE(ConfigError);
|
||||||
|
ERROR_DECLARE(FileInvalidError);
|
||||||
|
ERROR_DECLARE(FormatError);
|
||||||
|
ERROR_DECLARE(CommandRequiredError);
|
||||||
|
ERROR_DECLARE(OptionInvalidError);
|
||||||
|
ERROR_DECLARE(OptionInvalidValueError);
|
||||||
|
ERROR_DECLARE(OptionInvalidRangeError);
|
||||||
|
ERROR_DECLARE(OptionInvalidPairError);
|
||||||
|
ERROR_DECLARE(OptionDuplicateKeyError);
|
||||||
|
ERROR_DECLARE(OptionNegateError);
|
||||||
|
ERROR_DECLARE(OptionRequiredError);
|
||||||
|
ERROR_DECLARE(PostmasterRunningError);
|
||||||
|
ERROR_DECLARE(ProtocolError);
|
||||||
|
ERROR_DECLARE(PathNotEmptyError);
|
||||||
|
ERROR_DECLARE(FileOpenError);
|
||||||
|
ERROR_DECLARE(FileReadError);
|
||||||
|
ERROR_DECLARE(ParamRequiredError);
|
||||||
|
ERROR_DECLARE(ArchiveMismatchError);
|
||||||
|
ERROR_DECLARE(ArchiveDuplicateError);
|
||||||
|
ERROR_DECLARE(VersionNotSupportedError);
|
||||||
|
ERROR_DECLARE(PathCreateError);
|
||||||
|
ERROR_DECLARE(CommandInvalidError);
|
||||||
|
ERROR_DECLARE(HostConnectError);
|
||||||
|
ERROR_DECLARE(LockAcquireError);
|
||||||
|
ERROR_DECLARE(BackupMismatchError);
|
||||||
|
ERROR_DECLARE(FileSyncError);
|
||||||
|
ERROR_DECLARE(PathOpenError);
|
||||||
|
ERROR_DECLARE(PathSyncError);
|
||||||
|
ERROR_DECLARE(FileMissingError);
|
||||||
|
ERROR_DECLARE(DbConnectError);
|
||||||
|
ERROR_DECLARE(DbQueryError);
|
||||||
|
ERROR_DECLARE(DbMismatchError);
|
||||||
|
ERROR_DECLARE(DbTimeoutError);
|
||||||
|
ERROR_DECLARE(FileRemoveError);
|
||||||
|
ERROR_DECLARE(PathRemoveError);
|
||||||
|
ERROR_DECLARE(StopError);
|
||||||
|
ERROR_DECLARE(TermError);
|
||||||
|
ERROR_DECLARE(FileWriteError);
|
||||||
|
ERROR_DECLARE(ProtocolTimeoutError);
|
||||||
|
ERROR_DECLARE(FeatureNotSupportedError);
|
||||||
|
ERROR_DECLARE(ArchiveCommandInvalidError);
|
||||||
|
ERROR_DECLARE(LinkExpectedError);
|
||||||
|
ERROR_DECLARE(LinkDestinationError);
|
||||||
|
ERROR_DECLARE(TablespaceInPgdataError);
|
||||||
|
ERROR_DECLARE(HostInvalidError);
|
||||||
|
ERROR_DECLARE(PathMissingError);
|
||||||
|
ERROR_DECLARE(FileMoveError);
|
||||||
|
ERROR_DECLARE(BackupSetInvalidError);
|
||||||
|
ERROR_DECLARE(TablespaceMapError);
|
||||||
|
ERROR_DECLARE(PathTypeError);
|
||||||
|
ERROR_DECLARE(LinkMapError);
|
||||||
|
ERROR_DECLARE(FileCloseError);
|
||||||
|
ERROR_DECLARE(DbMissingError);
|
||||||
|
ERROR_DECLARE(DbInvalidError);
|
||||||
|
ERROR_DECLARE(ArchiveTimeoutError);
|
||||||
|
ERROR_DECLARE(FileModeError);
|
||||||
|
ERROR_DECLARE(OptionMultipleValueError);
|
||||||
|
ERROR_DECLARE(ProtocolOutputRequiredError);
|
||||||
|
ERROR_DECLARE(LinkOpenError);
|
||||||
|
ERROR_DECLARE(ArchiveDisabledError);
|
||||||
|
ERROR_DECLARE(FileOwnerError);
|
||||||
|
ERROR_DECLARE(UserMissingError);
|
||||||
|
ERROR_DECLARE(OptionCommandError);
|
||||||
|
ERROR_DECLARE(GroupMissingError);
|
||||||
|
ERROR_DECLARE(PathExistsError);
|
||||||
|
ERROR_DECLARE(FileExistsError);
|
||||||
|
ERROR_DECLARE(MemoryError);
|
||||||
|
ERROR_DECLARE(CipherError);
|
||||||
|
ERROR_DECLARE(ParamInvalidError);
|
||||||
|
ERROR_DECLARE(RuntimeError);
|
||||||
|
ERROR_DECLARE(InvalidError);
|
||||||
|
ERROR_DECLARE(UnhandledError);
|
||||||
|
ERROR_DECLARE(UnknownError);
|
||||||
|
|
||||||
|
#endif
|
@ -8,6 +8,23 @@ Error Handler
|
|||||||
|
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Represents an error type
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
struct ErrorType
|
||||||
|
{
|
||||||
|
const int code;
|
||||||
|
const char *name;
|
||||||
|
const struct ErrorType *parentType;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Macro for defining new error types
|
||||||
|
#define ERROR_DEFINE(code, name, parentType) \
|
||||||
|
const ErrorType name = {code, #name, &parentType}
|
||||||
|
|
||||||
|
// Include error type definitions
|
||||||
|
#include "common/error.auto.c"
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Maximum allowed number of nested try blocks
|
Maximum allowed number of nested try blocks
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
@ -59,6 +76,75 @@ The temp buffer is required because the error message being passed might be the
|
|||||||
static char messageBuffer[ERROR_MESSAGE_BUFFER_SIZE];
|
static char messageBuffer[ERROR_MESSAGE_BUFFER_SIZE];
|
||||||
static char messageBufferTemp[ERROR_MESSAGE_BUFFER_SIZE];
|
static char messageBufferTemp[ERROR_MESSAGE_BUFFER_SIZE];
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error type code
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
int
|
||||||
|
errorTypeCode(const ErrorType *errorType)
|
||||||
|
{
|
||||||
|
return errorType->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Get error type using a code
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
const ErrorType *
|
||||||
|
errorTypeFromCode(int code)
|
||||||
|
{
|
||||||
|
// Search for error type by code
|
||||||
|
int errorTypeIdx = 0;
|
||||||
|
const ErrorType *result = errorTypeList[errorTypeIdx];
|
||||||
|
|
||||||
|
while (result != NULL)
|
||||||
|
{
|
||||||
|
if (result->code == code)
|
||||||
|
break;
|
||||||
|
|
||||||
|
result = errorTypeList[++errorTypeIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error if type was not found
|
||||||
|
if (result == NULL)
|
||||||
|
THROW(AssertError, "could not find error type for code '%d'", code);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error type name
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
const char *
|
||||||
|
errorTypeName(const ErrorType *errorType)
|
||||||
|
{
|
||||||
|
return errorType->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Error type parent
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
const ErrorType *
|
||||||
|
errorTypeParent(const ErrorType *errorType)
|
||||||
|
{
|
||||||
|
return errorType->parentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Does the child error type extend the parent error type?
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
bool
|
||||||
|
errorTypeExtends(const ErrorType *child, const ErrorType *parent)
|
||||||
|
{
|
||||||
|
// Search for the parent
|
||||||
|
for (; child && errorTypeParent(child) != child; child = (ErrorType *)errorTypeParent(child))
|
||||||
|
{
|
||||||
|
if (errorTypeParent(child) == parent)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parent was not found
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Error type
|
Error type
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
|
@ -39,11 +39,31 @@ IMPORTANT: Never call return from within any of the error-handling blocks.
|
|||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
#include "common/errorType.h"
|
|
||||||
#include "common/type.h"
|
#include "common/type.h"
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Error accessor functions
|
Error type object
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
typedef struct ErrorType ErrorType;
|
||||||
|
|
||||||
|
// Macro for declaring new error types
|
||||||
|
#define ERROR_DECLARE(name) \
|
||||||
|
extern const ErrorType name
|
||||||
|
|
||||||
|
// Include error type declarations
|
||||||
|
#include "common/error.auto.h"
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Functions to get information about a generic error type
|
||||||
|
***********************************************************************************************************************************/
|
||||||
|
int errorTypeCode(const ErrorType *errorType);
|
||||||
|
const ErrorType *errorTypeFromCode(int code);
|
||||||
|
const char *errorTypeName(const ErrorType *errorType);
|
||||||
|
const ErrorType *errorTypeParent(const ErrorType *errorType);
|
||||||
|
bool errorTypeExtends(const ErrorType *child, const ErrorType *parent);
|
||||||
|
|
||||||
|
/***********************************************************************************************************************************
|
||||||
|
Functions to get information about the current error
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
const ErrorType *errorType();
|
const ErrorType *errorType();
|
||||||
int errorCode();
|
int errorCode();
|
||||||
|
@ -1,148 +0,0 @@
|
|||||||
/***********************************************************************************************************************************
|
|
||||||
Application-Defined Errors
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
#include "common/error.h"
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Error code range -- chosen to not overlap with defined return values
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
#define ERROR_CODE_MIN 25
|
|
||||||
#define ERROR_CODE_MAX 125
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Represents an error type
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
struct ErrorType
|
|
||||||
{
|
|
||||||
const int code;
|
|
||||||
const char *name;
|
|
||||||
const struct ErrorType *parentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Macro to create error structs
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
#define ERROR_DEFINE(code, name, parentType) \
|
|
||||||
const ErrorType name = {code, #name, &parentType}
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Define errors
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN, AssertError, RuntimeError);
|
|
||||||
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 04, FormatError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 05, CommandRequiredError, FormatError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 06, OptionInvalidError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 07, OptionInvalidValueError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 12, OptionRequiredError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 16, FileOpenError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 17, FileReadError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 18, ParamRequiredError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 19, ArchiveMismatchError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 23, CommandInvalidError, FormatError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 28, PathOpenError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 39, FileWriteError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 57, ArchiveTimeoutError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 69, MemoryError, RuntimeError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 70, CipherError, FormatError);
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MIN + 71, ParamInvalidError, RuntimeError);
|
|
||||||
|
|
||||||
ERROR_DEFINE(ERROR_CODE_MAX, RuntimeError, RuntimeError);
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Place errors in an array so they can be found by code
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
static const ErrorType *errorTypeList[] =
|
|
||||||
{
|
|
||||||
&AssertError,
|
|
||||||
|
|
||||||
&FormatError,
|
|
||||||
&CommandRequiredError,
|
|
||||||
&OptionInvalidError,
|
|
||||||
&OptionInvalidValueError,
|
|
||||||
&OptionRequiredError,
|
|
||||||
&FileOpenError,
|
|
||||||
&FileReadError,
|
|
||||||
&ParamRequiredError,
|
|
||||||
&ArchiveMismatchError,
|
|
||||||
&CommandInvalidError,
|
|
||||||
&PathOpenError,
|
|
||||||
&FileWriteError,
|
|
||||||
&ArchiveTimeoutError,
|
|
||||||
&MemoryError,
|
|
||||||
&CipherError,
|
|
||||||
&ParamInvalidError,
|
|
||||||
|
|
||||||
&RuntimeError,
|
|
||||||
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Error type code
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
int
|
|
||||||
errorTypeCode(const ErrorType *errorType)
|
|
||||||
{
|
|
||||||
return errorType->code;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Get error type using a code
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
const ErrorType *
|
|
||||||
errorTypeFromCode(int code)
|
|
||||||
{
|
|
||||||
// Search for error type by code
|
|
||||||
int errorTypeIdx = 0;
|
|
||||||
const ErrorType *result = errorTypeList[errorTypeIdx];
|
|
||||||
|
|
||||||
while (result != NULL)
|
|
||||||
{
|
|
||||||
if (result->code == code)
|
|
||||||
break;
|
|
||||||
|
|
||||||
result = errorTypeList[++errorTypeIdx];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error if type was not found
|
|
||||||
if (result == NULL)
|
|
||||||
THROW(AssertError, "could not find error type for code '%d'", code);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Error type name
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
const char *
|
|
||||||
errorTypeName(const ErrorType *errorType)
|
|
||||||
{
|
|
||||||
return errorType->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Error type parent
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
const ErrorType *
|
|
||||||
errorTypeParent(const ErrorType *errorType)
|
|
||||||
{
|
|
||||||
return errorType->parentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
|
||||||
Does the child error type extend the parent error type?
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
bool
|
|
||||||
errorTypeExtends(const ErrorType *child, const ErrorType *parent)
|
|
||||||
{
|
|
||||||
// Search for the parent
|
|
||||||
for (; child && errorTypeParent(child) != child; child = (ErrorType *)errorTypeParent(child))
|
|
||||||
{
|
|
||||||
if (errorTypeParent(child) == parent)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parent was not found
|
|
||||||
return false;
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/***********************************************************************************************************************************
|
|
||||||
Application-Defined Errors
|
|
||||||
***********************************************************************************************************************************/
|
|
||||||
#ifndef ERROR_TYPE_H
|
|
||||||
#define ERROR_TYPE_H
|
|
||||||
|
|
||||||
#include "common/type.h"
|
|
||||||
|
|
||||||
// Represents an error type
|
|
||||||
typedef struct ErrorType ErrorType;
|
|
||||||
|
|
||||||
// Macros for declaring and defining new error types
|
|
||||||
#define ERROR_DECLARE(name) \
|
|
||||||
extern const ErrorType name
|
|
||||||
|
|
||||||
// Error types
|
|
||||||
ERROR_DECLARE(AssertError);
|
|
||||||
|
|
||||||
ERROR_DECLARE(FormatError);
|
|
||||||
ERROR_DECLARE(CommandRequiredError);
|
|
||||||
ERROR_DECLARE(OptionInvalidError);
|
|
||||||
ERROR_DECLARE(OptionInvalidValueError);
|
|
||||||
ERROR_DECLARE(OptionRequiredError);
|
|
||||||
ERROR_DECLARE(FileOpenError);
|
|
||||||
ERROR_DECLARE(FileReadError);
|
|
||||||
ERROR_DECLARE(ParamRequiredError);
|
|
||||||
ERROR_DECLARE(ArchiveMismatchError);
|
|
||||||
ERROR_DECLARE(CommandInvalidError);
|
|
||||||
ERROR_DECLARE(PathOpenError);
|
|
||||||
ERROR_DECLARE(FileWriteError);
|
|
||||||
ERROR_DECLARE(ArchiveTimeoutError);
|
|
||||||
ERROR_DECLARE(MemoryError);
|
|
||||||
ERROR_DECLARE(CipherError);
|
|
||||||
ERROR_DECLARE(ParamInvalidError);
|
|
||||||
|
|
||||||
ERROR_DECLARE(RuntimeError);
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
int errorTypeCode(const ErrorType *errorType);
|
|
||||||
const ErrorType *errorTypeFromCode(int code);
|
|
||||||
const char *errorTypeName(const ErrorType *errorType);
|
|
||||||
const ErrorType *errorTypeParent(const ErrorType *errorType);
|
|
||||||
bool errorTypeExtends(const ErrorType *child, const ErrorType *parent);
|
|
||||||
|
|
||||||
#endif
|
|
@ -4,7 +4,7 @@ Memory Context Manager
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "common/errorType.h"
|
#include "common/error.h"
|
||||||
#include "common/memContext.h"
|
#include "common/memContext.h"
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
|
@ -5,7 +5,6 @@ Variant Data Type
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
#include "common/errorType.h"
|
|
||||||
#include "common/memContext.h"
|
#include "common/memContext.h"
|
||||||
#include "common/type/variant.h"
|
#include "common/type/variant.h"
|
||||||
|
|
||||||
|
2
test/Vagrantfile
vendored
2
test/Vagrantfile
vendored
@ -48,7 +48,7 @@ Vagrant.configure(2) do |config|
|
|||||||
#---------------------------------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------------------------------
|
||||||
echo 'Install Perl Modules' && date
|
echo 'Install Perl Modules' && date
|
||||||
apt-get install -y libdbd-pg-perl libio-socket-ssl-perl libxml-libxml-perl libxml-checker-perl libperl-critic-perl \
|
apt-get install -y libdbd-pg-perl libio-socket-ssl-perl libxml-libxml-perl libxml-checker-perl libperl-critic-perl \
|
||||||
libdevel-nytprof-perl
|
libdevel-nytprof-perl libyaml-perl
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------------------------------
|
||||||
echo 'Install Build Tools' && date
|
echo 'Install Build Tools' && date
|
||||||
|
@ -101,7 +101,7 @@ sub process
|
|||||||
"before_install:\n" .
|
"before_install:\n" .
|
||||||
" - sudo apt-get -qq update && sudo apt-get install libxml-checker-perl libdbd-pg-perl libperl-critic-perl" .
|
" - sudo apt-get -qq update && sudo apt-get install libxml-checker-perl libdbd-pg-perl libperl-critic-perl" .
|
||||||
" libtemplate-perl libpod-coverage-perl libtest-differences-perl libhtml-parser-perl lintian debhelper txt2man" .
|
" libtemplate-perl libpod-coverage-perl libtest-differences-perl libhtml-parser-perl lintian debhelper txt2man" .
|
||||||
" devscripts libjson-perl libio-socket-ssl-perl libxml-libxml-perl python-pip\n" .
|
" devscripts libjson-perl libio-socket-ssl-perl libxml-libxml-perl libyaml-perl python-pip\n" .
|
||||||
" - |\n" .
|
" - |\n" .
|
||||||
" # Install & Configure AWS CLI\n" .
|
" # Install & Configure AWS CLI\n" .
|
||||||
" pip install --upgrade --user awscli\n" .
|
" pip install --upgrade --user awscli\n" .
|
||||||
|
@ -127,7 +127,7 @@ my $oTestDef =
|
|||||||
&TESTDEF_COVERAGE =>
|
&TESTDEF_COVERAGE =>
|
||||||
{
|
{
|
||||||
'common/error' => TESTDEF_COVERAGE_FULL,
|
'common/error' => TESTDEF_COVERAGE_FULL,
|
||||||
'common/errorType' => TESTDEF_COVERAGE_FULL,
|
'common/error.auto' => TESTDEF_COVERAGE_NOCODE,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -27,8 +27,8 @@ testRun()
|
|||||||
{
|
{
|
||||||
exitSafe(true);
|
exitSafe(true);
|
||||||
testLogResult(
|
testLogResult(
|
||||||
"P00 ERROR: [125]: test error message\n"
|
"P00 ERROR: [122]: test error message\n"
|
||||||
"P00 INFO: archive-push command end: aborted with exception [125]");
|
"P00 INFO: archive-push command end: aborted with exception [122]");
|
||||||
}
|
}
|
||||||
TRY_END();
|
TRY_END();
|
||||||
}
|
}
|
||||||
|
10
test/test.pl
10
test/test.pl
@ -42,6 +42,8 @@ use pgBackRestBuild::Build::Common;
|
|||||||
use pgBackRestBuild::Config::Build;
|
use pgBackRestBuild::Config::Build;
|
||||||
use pgBackRestBuild::Config::BuildDefine;
|
use pgBackRestBuild::Config::BuildDefine;
|
||||||
use pgBackRestBuild::Config::BuildParse;
|
use pgBackRestBuild::Config::BuildParse;
|
||||||
|
use pgBackRestBuild::Error::Build;
|
||||||
|
use pgBackRestBuild::Error::Data;
|
||||||
|
|
||||||
use BackRestDoc::Custom::DocCustomRelease;
|
use BackRestDoc::Custom::DocCustomRelease;
|
||||||
|
|
||||||
@ -298,6 +300,8 @@ eval
|
|||||||
{
|
{
|
||||||
# Auto-generate C files
|
# Auto-generate C files
|
||||||
#---------------------------------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
errorDefineLoad(${$oStorageBackRest->get("build/error.yaml")});
|
||||||
|
|
||||||
my $rhBuild =
|
my $rhBuild =
|
||||||
{
|
{
|
||||||
'config' =>
|
'config' =>
|
||||||
@ -317,6 +321,12 @@ eval
|
|||||||
&BLD_DATA => buildConfigParse(),
|
&BLD_DATA => buildConfigParse(),
|
||||||
&BLD_PATH => 'config',
|
&BLD_PATH => 'config',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'error' =>
|
||||||
|
{
|
||||||
|
&BLD_DATA => buildError(),
|
||||||
|
&BLD_PATH => 'common',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
buildAll("${strBackRestBase}/src", $rhBuild);
|
buildAll("${strBackRestBase}/src", $rhBuild);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user