2014-06-07 18:51:27 +03:00
|
|
|
####################################################################################################################################
|
|
|
|
# EXCEPTION MODULE
|
|
|
|
####################################################################################################################################
|
|
|
|
package BackRest::Exception;
|
|
|
|
|
|
|
|
use strict;
|
2015-03-03 07:57:20 +02:00
|
|
|
use warnings FATAL => qw(all);
|
2015-06-14 00:25:49 +02:00
|
|
|
use Carp qw(confess longmess);
|
|
|
|
|
2015-01-24 01:28:39 +02:00
|
|
|
use Exporter qw(import);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Exception Codes
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant
|
|
|
|
{
|
2015-03-08 19:26:09 +02:00
|
|
|
ERROR_ASSERT => 100,
|
|
|
|
ERROR_CHECKSUM => 101,
|
|
|
|
ERROR_CONFIG => 102,
|
2015-03-12 18:15:19 +02:00
|
|
|
ERROR_FILE_INVALID => 103,
|
|
|
|
ERROR_FORMAT => 104,
|
2015-06-18 22:55:09 +02:00
|
|
|
ERROR_COMMAND_REQUIRED => 105,
|
2015-03-08 19:26:09 +02:00
|
|
|
ERROR_OPTION_INVALID => 106,
|
|
|
|
ERROR_OPTION_INVALID_VALUE => 107,
|
2015-03-12 18:15:19 +02:00
|
|
|
ERROR_OPTION_INVALID_RANGE => 108,
|
|
|
|
ERROR_OPTION_INVALID_PAIR => 109,
|
|
|
|
ERROR_OPTION_DUPLICATE_KEY => 110,
|
|
|
|
ERROR_OPTION_NEGATE => 111,
|
|
|
|
ERROR_OPTION_REQUIRED => 112,
|
|
|
|
ERROR_POSTMASTER_RUNNING => 113,
|
|
|
|
ERROR_PROTOCOL => 114,
|
2015-04-01 21:58:33 +02:00
|
|
|
ERROR_RESTORE_PATH_NOT_EMPTY => 115,
|
|
|
|
ERROR_FILE_OPEN => 116,
|
|
|
|
ERROR_FILE_READ => 117,
|
|
|
|
ERROR_PARAM_REQUIRED => 118,
|
|
|
|
ERROR_ARCHIVE_MISMATCH => 119,
|
|
|
|
ERROR_ARCHIVE_DUPLICATE => 120,
|
2015-04-22 22:39:53 +02:00
|
|
|
ERROR_VERSION_NOT_SUPPORTED => 121,
|
2015-05-26 21:29:42 +02:00
|
|
|
ERROR_PATH_CREATE => 122,
|
2015-06-18 22:55:09 +02:00
|
|
|
ERROR_COMMAND_INVALID => 123,
|
2015-05-29 18:26:31 +02:00
|
|
|
ERROR_HOST_CONNECT => 124,
|
2015-05-29 22:31:12 +02:00
|
|
|
ERROR_LOCK_ACQUIRE => 125,
|
2015-06-14 00:25:49 +02:00
|
|
|
ERROR_BACKUP_MISMATCH => 126,
|
2015-06-17 18:53:33 +02:00
|
|
|
ERROR_FILE_SYNC => 127,
|
|
|
|
ERROR_PATH_OPEN => 128,
|
|
|
|
ERROR_PATH_SYNC => 129,
|
2015-06-22 15:51:16 +02:00
|
|
|
ERROR_FILE_MISSING => 130,
|
2015-08-05 18:32:12 +02:00
|
|
|
ERROR_DB_CONNECT => 131,
|
|
|
|
ERROR_DB_QUERY => 132,
|
2015-08-06 04:05:45 +02:00
|
|
|
ERROR_DB_MISMATCH => 133,
|
2015-05-29 18:26:31 +02:00
|
|
|
|
|
|
|
ERROR_UNKNOWN => 199
|
2015-01-24 01:28:39 +02:00
|
|
|
};
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
our @EXPORT = qw(ERROR_ASSERT ERROR_CHECKSUM ERROR_CONFIG ERROR_FILE_INVALID ERROR_FORMAT ERROR_COMMAND_REQUIRED
|
2015-03-12 18:15:19 +02:00
|
|
|
ERROR_OPTION_INVALID ERROR_OPTION_INVALID_VALUE ERROR_OPTION_INVALID_RANGE ERROR_OPTION_INVALID_PAIR
|
|
|
|
ERROR_OPTION_DUPLICATE_KEY ERROR_OPTION_NEGATE ERROR_OPTION_REQUIRED ERROR_POSTMASTER_RUNNING ERROR_PROTOCOL
|
2015-04-01 21:58:33 +02:00
|
|
|
ERROR_RESTORE_PATH_NOT_EMPTY ERROR_FILE_OPEN ERROR_FILE_READ ERROR_PARAM_REQUIRED ERROR_ARCHIVE_MISMATCH
|
2015-06-18 22:55:09 +02:00
|
|
|
ERROR_ARCHIVE_DUPLICATE ERROR_VERSION_NOT_SUPPORTED ERROR_PATH_CREATE ERROR_COMMAND_INVALID ERROR_HOST_CONNECT
|
2015-06-22 15:51:16 +02:00
|
|
|
ERROR_UNKNOWN ERROR_LOCK_ACQUIRE ERROR_BACKUP_MISMATCH ERROR_FILE_SYNC ERROR_PATH_OPEN ERROR_PATH_SYNC
|
2015-08-06 04:05:45 +02:00
|
|
|
ERROR_FILE_MISSING ERROR_DB_CONNECT ERROR_DB_QUERY ERROR_DB_MISMATCH);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2014-10-09 23:01:06 +03:00
|
|
|
####################################################################################################################################
|
|
|
|
# CONSTRUCTOR
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift; # Class name
|
|
|
|
my $iCode = shift; # Error code
|
|
|
|
my $strMessage = shift; # ErrorMessage
|
2015-06-14 00:25:49 +02:00
|
|
|
my $strTrace = shift; # Stack trace
|
2014-06-07 18:51:27 +03:00
|
|
|
|
2014-10-09 23:01:06 +03:00
|
|
|
# Create the class hash
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
# Initialize exception
|
|
|
|
$self->{iCode} = $iCode;
|
|
|
|
$self->{strMessage} = $strMessage;
|
2015-06-14 00:25:49 +02:00
|
|
|
$self->{strTrace} = $strTrace;
|
2014-10-09 23:01:06 +03:00
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
2014-06-07 18:51:27 +03:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# CODE
|
|
|
|
####################################################################################################################################
|
|
|
|
sub code
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
return $self->{iCode};
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# MESSAGE
|
|
|
|
####################################################################################################################################
|
|
|
|
sub message
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
return $self->{strMessage};
|
|
|
|
}
|
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# TRACE
|
|
|
|
####################################################################################################################################
|
|
|
|
sub trace
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
return $self->{strTrace};
|
|
|
|
}
|
|
|
|
|
2014-10-10 22:13:28 +03:00
|
|
|
1;
|