PageRenderTime 274ms CodeModel.GetById 91ms app.highlight 118ms RepoModel.GetById 63ms app.codeStats 0ms

/mordor/pq/exception.h

http://github.com/mozy/mordor
C Header | 148 lines | 126 code | 21 blank | 1 comment | 0 complexity | 0919764d48b1525e757d3c59a2959db3 MD5 | raw file
  1#ifndef __MORDOR_PQ_EXCEPTION_H__
  2#define __MORDOR_PQ_EXCEPTION_H__
  3// Copyright (c) 2010 - Mozy, Inc.
  4
  5#include <libpq-fe.h>
  6
  7#include "mordor/exception.h"
  8
  9namespace Mordor {
 10namespace PQ {
 11
 12struct Exception : virtual ::Mordor::Exception
 13{
 14    Exception(const std::string &message)
 15        : m_message(message)
 16    {}
 17    Exception()
 18    {}
 19    ~Exception() throw () {}
 20
 21    const char *what() const throw () { return m_message.c_str(); }
 22private:
 23    std::string m_message;
 24};
 25
 26#define DEFINE_MORDOR_PQ_EXCEPTION(Exception, Base)                             \
 27struct Exception : Base                                                         \
 28{                                                                               \
 29    Exception()                                                                 \
 30    {}                                                                          \
 31    Exception(const std::string &message)                                       \
 32        : Base(message)                                                         \
 33    {}                                                                          \
 34};
 35
 36DEFINE_MORDOR_PQ_EXCEPTION(ConnectionException, Exception);
 37
 38DEFINE_MORDOR_PQ_EXCEPTION(DataException, Exception);
 39DEFINE_MORDOR_PQ_EXCEPTION(ArraySubscriptError, DataException);
 40DEFINE_MORDOR_PQ_EXCEPTION(CharacterNotInRepertoireException, DataException);
 41DEFINE_MORDOR_PQ_EXCEPTION(OverflowException, DataException);
 42DEFINE_MORDOR_PQ_EXCEPTION(DivisionByZeroException, DataException);
 43DEFINE_MORDOR_PQ_EXCEPTION(AssignmentError, DataException);
 44DEFINE_MORDOR_PQ_EXCEPTION(EscapeCharacterConflictException, DataException);
 45DEFINE_MORDOR_PQ_EXCEPTION(InvalidArgumentException, DataException);
 46DEFINE_MORDOR_PQ_EXCEPTION(NullValueNotAllowedException, DataException);
 47
 48DEFINE_MORDOR_PQ_EXCEPTION(IntegrityConstraintViolationException, Exception)
 49DEFINE_MORDOR_PQ_EXCEPTION(RestrictViolationException, IntegrityConstraintViolationException)
 50DEFINE_MORDOR_PQ_EXCEPTION(NotNullViolationException, IntegrityConstraintViolationException)
 51DEFINE_MORDOR_PQ_EXCEPTION(ForeignKeyViolationException, IntegrityConstraintViolationException)
 52DEFINE_MORDOR_PQ_EXCEPTION(UniqueViolationException, IntegrityConstraintViolationException)
 53DEFINE_MORDOR_PQ_EXCEPTION(CheckViolationException, IntegrityConstraintViolationException)
 54
 55DEFINE_MORDOR_PQ_EXCEPTION(InvalidTransactionStateException, Exception);
 56DEFINE_MORDOR_PQ_EXCEPTION(ActiveTransactionException, InvalidTransactionStateException);
 57DEFINE_MORDOR_PQ_EXCEPTION(BranchTransactionAlreadyActiveException, InvalidTransactionStateException);
 58DEFINE_MORDOR_PQ_EXCEPTION(HeldCursorRequiresSameIsolationLevelException, InvalidTransactionStateException);
 59DEFINE_MORDOR_PQ_EXCEPTION(InappropriateAccessModeForBranchTransactionException, InvalidTransactionStateException);
 60DEFINE_MORDOR_PQ_EXCEPTION(InappropriateIsolationLevelForBranchTransactionException, InvalidTransactionStateException);
 61DEFINE_MORDOR_PQ_EXCEPTION(NoActiveTransactionForBranchException, InvalidTransactionStateException);
 62DEFINE_MORDOR_PQ_EXCEPTION(ReadOnlyTransactionException, InvalidTransactionStateException);
 63DEFINE_MORDOR_PQ_EXCEPTION(SchemaAndDataStatementMixingNotSupportedException, InvalidTransactionStateException);
 64DEFINE_MORDOR_PQ_EXCEPTION(NoActiveTransactionException, InvalidTransactionStateException);
 65DEFINE_MORDOR_PQ_EXCEPTION(InFailedTransactionException, InvalidTransactionStateException);
 66
 67DEFINE_MORDOR_PQ_EXCEPTION(TransactionRollbackException, Exception);
 68DEFINE_MORDOR_PQ_EXCEPTION(TransactionIntegrityConstraintViolationException, TransactionRollbackException);
 69DEFINE_MORDOR_PQ_EXCEPTION(SerializationFailureException, TransactionRollbackException);
 70DEFINE_MORDOR_PQ_EXCEPTION(StatementCompletionUnknownException, TransactionRollbackException);
 71DEFINE_MORDOR_PQ_EXCEPTION(DeadlockDetectedException, TransactionRollbackException);
 72
 73DEFINE_MORDOR_PQ_EXCEPTION(AccessRuleViolationException, Exception);
 74DEFINE_MORDOR_PQ_EXCEPTION(SyntaxError, AccessRuleViolationException);
 75DEFINE_MORDOR_PQ_EXCEPTION(InsufficientPrivilegeException, AccessRuleViolationException);
 76DEFINE_MORDOR_PQ_EXCEPTION(CannotCoerceException, AccessRuleViolationException);
 77DEFINE_MORDOR_PQ_EXCEPTION(GroupingError, SyntaxError);
 78DEFINE_MORDOR_PQ_EXCEPTION(WindowingError, SyntaxError);
 79DEFINE_MORDOR_PQ_EXCEPTION(InvalidRecursionException, SyntaxError);
 80DEFINE_MORDOR_PQ_EXCEPTION(InvalidForeignKeyException, AccessRuleViolationException);
 81DEFINE_MORDOR_PQ_EXCEPTION(InvalidNameException, SyntaxError);
 82DEFINE_MORDOR_PQ_EXCEPTION(NameTooLongException, SyntaxError);
 83DEFINE_MORDOR_PQ_EXCEPTION(ReservedNameException, SyntaxError);
 84DEFINE_MORDOR_PQ_EXCEPTION(DatatypeMismatchException, AccessRuleViolationException);
 85DEFINE_MORDOR_PQ_EXCEPTION(IndeterminateDatatypeException, AccessRuleViolationException);
 86DEFINE_MORDOR_PQ_EXCEPTION(WrongObjectTypeException, AccessRuleViolationException);
 87DEFINE_MORDOR_PQ_EXCEPTION(UndefinedColumnException, AccessRuleViolationException);
 88DEFINE_MORDOR_PQ_EXCEPTION(UndefinedFunctionException, AccessRuleViolationException);
 89DEFINE_MORDOR_PQ_EXCEPTION(UndefinedTableException, AccessRuleViolationException);
 90DEFINE_MORDOR_PQ_EXCEPTION(UndefinedParameterException, AccessRuleViolationException);
 91DEFINE_MORDOR_PQ_EXCEPTION(UndefinedObjectException, AccessRuleViolationException);
 92DEFINE_MORDOR_PQ_EXCEPTION(DuplicateColumnException, AccessRuleViolationException);
 93DEFINE_MORDOR_PQ_EXCEPTION(DuplicateCursorException, AccessRuleViolationException);
 94DEFINE_MORDOR_PQ_EXCEPTION(DuplicateDatabaseException, AccessRuleViolationException);
 95DEFINE_MORDOR_PQ_EXCEPTION(DuplicateFunctionException, AccessRuleViolationException);
 96DEFINE_MORDOR_PQ_EXCEPTION(DuplicatePreparedStatementException, AccessRuleViolationException);
 97DEFINE_MORDOR_PQ_EXCEPTION(DuplicateSchemaException, AccessRuleViolationException);
 98DEFINE_MORDOR_PQ_EXCEPTION(DuplicateTableException, AccessRuleViolationException);
 99DEFINE_MORDOR_PQ_EXCEPTION(DuplicateAliasException, AccessRuleViolationException);
100DEFINE_MORDOR_PQ_EXCEPTION(DuplicateObjectException, AccessRuleViolationException);
101DEFINE_MORDOR_PQ_EXCEPTION(AmbiguousColumnException, AccessRuleViolationException);
102DEFINE_MORDOR_PQ_EXCEPTION(AmbiguousFunctionException, AccessRuleViolationException);
103DEFINE_MORDOR_PQ_EXCEPTION(AmbiguousParameterException, AccessRuleViolationException);
104DEFINE_MORDOR_PQ_EXCEPTION(AmbiguousAliasException, AccessRuleViolationException);
105DEFINE_MORDOR_PQ_EXCEPTION(InvalidColumnReferenceException, AccessRuleViolationException);
106DEFINE_MORDOR_PQ_EXCEPTION(InvalidColumnDefinitionException, AccessRuleViolationException);
107DEFINE_MORDOR_PQ_EXCEPTION(InvalidCursorDefinitionException, AccessRuleViolationException);
108DEFINE_MORDOR_PQ_EXCEPTION(InvalidDatabaseDefinitionException, AccessRuleViolationException);
109DEFINE_MORDOR_PQ_EXCEPTION(InvalidFunctionDefinitionException, AccessRuleViolationException);
110DEFINE_MORDOR_PQ_EXCEPTION(InvalidPreparedStatementDefinitionException, AccessRuleViolationException);
111DEFINE_MORDOR_PQ_EXCEPTION(InvalidSchemaDefinitionException, AccessRuleViolationException);
112DEFINE_MORDOR_PQ_EXCEPTION(InvalidTableDefinitionException, AccessRuleViolationException);
113DEFINE_MORDOR_PQ_EXCEPTION(InvalidObjectDefinitionException, AccessRuleViolationException);
114
115DEFINE_MORDOR_PQ_EXCEPTION(InsufficientResourcesException, Exception);
116DEFINE_MORDOR_PQ_EXCEPTION(DiskFullException, InsufficientResourcesException);
117DEFINE_MORDOR_PQ_EXCEPTION(OutOfMemoryException, InsufficientResourcesException);
118DEFINE_MORDOR_PQ_EXCEPTION(TooManyConnectionsException, InsufficientResourcesException);
119
120DEFINE_MORDOR_PQ_EXCEPTION(ProgramLimitExceededException, Exception);
121DEFINE_MORDOR_PQ_EXCEPTION(StatementTooComplexException, ProgramLimitExceededException);
122DEFINE_MORDOR_PQ_EXCEPTION(TooManyColumnsException, ProgramLimitExceededException);
123DEFINE_MORDOR_PQ_EXCEPTION(TooManyArgumentsException, ProgramLimitExceededException);
124
125DEFINE_MORDOR_PQ_EXCEPTION(OperatorInterventionException, Exception);
126DEFINE_MORDOR_PQ_EXCEPTION(QueryCanceledException, OperatorInterventionException);
127DEFINE_MORDOR_PQ_EXCEPTION(AdminShutdownException, OperatorInterventionException);
128DEFINE_MORDOR_PQ_EXCEPTION(CrashShutdownException, OperatorInterventionException);
129DEFINE_MORDOR_PQ_EXCEPTION(CannotConnectNowException, OperatorInterventionException);
130
131DEFINE_MORDOR_PQ_EXCEPTION(SystemError, Exception);
132DEFINE_MORDOR_PQ_EXCEPTION(IOError, SystemError);
133DEFINE_MORDOR_PQ_EXCEPTION(UndefinedFileException, SystemError);
134DEFINE_MORDOR_PQ_EXCEPTION(DuplicateFileException, SystemError);
135
136DEFINE_MORDOR_PQ_EXCEPTION(ConfigFileError, Exception);
137DEFINE_MORDOR_PQ_EXCEPTION(LockFileExistsException, ConfigFileError);
138
139DEFINE_MORDOR_PQ_EXCEPTION(InternalError, Exception);
140DEFINE_MORDOR_PQ_EXCEPTION(DataCorruptedException, InternalError);
141DEFINE_MORDOR_PQ_EXCEPTION(IndexCorruptedException, InternalError);
142
143void throwException(PGconn *conn);
144void throwException(PGresult *result);
145
146}}
147
148#endif