|
| 1 | +import re |
| 2 | +import logging |
| 3 | + |
| 4 | +from py2neo import GraphError as graph_error, BindError as bind_error |
| 5 | +from py2neo.cypher.error import ClientError as client_error |
| 6 | +from py2neo.cypher import CypherTransactionError as cypher_transaction_error |
| 7 | +from py2neo.cypher.error.statement import InvalidType as invalid_type |
| 8 | +from py2neo.cypher import CypherError as cypher_error |
| 9 | +from py2neo.cypher.error.request import Invalid as invalid |
| 10 | +from py2neo.cypher.error.request import InvalidFormat as invalid_format |
| 11 | +from py2neo.cypher.error.schema import ConstraintAlreadyExists as constraint_already_exists |
| 12 | +from py2neo.cypher.error.schema import ConstraintVerificationFailure as constraint_verification_failure |
| 13 | +from py2neo.cypher.error.schema import ConstraintViolation as constraint_violation |
| 14 | +from py2neo.cypher.error.schema import IllegalTokenName as illegal_token_name |
| 15 | +from py2neo.cypher.error.schema import IndexAlreadyExists as index_already_exists |
| 16 | +from py2neo.cypher.error.schema import IndexBelongsToConstraint as index_belongs_to_constraint |
| 17 | +from py2neo.cypher.error.schema import LabelLimitReached as label_limit_reached |
| 18 | +from py2neo.cypher.error.schema import NoSuchConstraint as no_such_constraint |
| 19 | +from py2neo.cypher.error.schema import NoSuchIndex as no_such_index |
| 20 | +from py2neo.cypher.error.statement import ArithmeticError as statement_arithmetic_error |
| 21 | +from py2neo.cypher.error.statement import ConstraintViolation as statement_constraint_violation |
| 22 | +from py2neo.cypher.error.statement import EntityNotFound as entity_not_found |
| 23 | +from py2neo.cypher.error.statement import InvalidArguments as invalid_arguments |
| 24 | +from py2neo.cypher.error.statement import InvalidSemantics as invalid_semantics |
| 25 | +from py2neo.cypher.error.statement import InvalidSyntax as invalid_syntax |
| 26 | +from py2neo.cypher.error.statement import NoSuchLabel as no_such_label |
| 27 | +from py2neo.cypher.error.statement import NoSuchProperty as no_such_property |
| 28 | +from py2neo.cypher.error.statement import ParameterMissing as parameter_missing |
| 29 | +from py2neo.cypher.error.transaction import ConcurrentRequest as concurrent_request |
| 30 | +from py2neo.cypher.error.transaction import EventHandlerThrewException as event_handler_threw_exception |
| 31 | +from py2neo.cypher.error.transaction import InvalidType as transaction_invalid_type |
| 32 | +from py2neo.cypher.error.transaction import UnknownId as unknown_id |
| 33 | +from py2neo.cypher import DatabaseError as database_error |
| 34 | +from py2neo.cypher.error.schema import ConstraintCreationFailure as constraint_creation_failure |
| 35 | +from py2neo.cypher.error.schema import ConstraintDropFailure as constraint_drop_failure |
| 36 | +from py2neo.cypher.error.schema import IndexCreationFailure as index_creation_failure |
| 37 | +from py2neo.cypher.error.schema import IndexDropFailure as index_drop_failure |
| 38 | +from py2neo.cypher.error.schema import NoSuchLabel as schema_no_such_label |
| 39 | +from py2neo.cypher.error.schema import NoSuchPropertyKey as schema_no_such_property |
| 40 | +from py2neo.cypher.error.schema import NoSuchRelationshipType as no_such_relationship_type |
| 41 | +from py2neo.cypher.error.schema import NoSuchSchemaRule as no_such_schema_rule |
| 42 | +from py2neo.cypher.error.statement import ExecutionFailure as execution_failure |
| 43 | +from py2neo.cypher.error.transaction import CouldNotBegin as could_not_begin |
| 44 | +from py2neo.cypher.error.transaction import CouldNotCommit as could_not_commit |
| 45 | +from py2neo.cypher.error.transaction import CouldNotRollback as could_not_rollback |
| 46 | +from py2neo.cypher.error.transaction import ReleaseLocksFailed as release_locks_failed |
| 47 | +from py2neo.cypher import TransientError as transient_error |
| 48 | +from py2neo.cypher.error.network import UnknownFailure as unknown_failure |
| 49 | +from py2neo.cypher.error.statement import ExternalResourceFailure as external_resource_failure |
| 50 | +from py2neo.cypher.error.transaction import AcquireLockTimeout as acquire_lock_timeout |
| 51 | + |
| 52 | +from mongo_connector import errors |
| 53 | +from mongo_connector.errors import OperationFailed |
| 54 | + |
| 55 | + |
| 56 | +LOG = logging.getLogger(__name__) |
| 57 | + |
| 58 | +class Neo4jOperationFailed(OperationFailed): |
| 59 | + """Raised for failed commands on the destination database |
| 60 | + """ |
| 61 | + # print("An error ocurred. Please check mongo-connector.log file") |
| 62 | + |
| 63 | +class ErrorHandler(object): |
| 64 | + def __init__(self): |
| 65 | + self.error_hash = { |
| 66 | + graph_error: Neo4jOperationFailed, |
| 67 | + bind_error: errors.ConnectionFailed, |
| 68 | + invalid_type: Neo4jOperationFailed, |
| 69 | + cypher_transaction_error: Neo4jOperationFailed, |
| 70 | + cypher_error: Neo4jOperationFailed, |
| 71 | + client_error: Neo4jOperationFailed, |
| 72 | + invalid: Neo4jOperationFailed, |
| 73 | + invalid_format: Neo4jOperationFailed, |
| 74 | + constraint_already_exists: Neo4jOperationFailed, |
| 75 | + constraint_verification_failure: Neo4jOperationFailed, |
| 76 | + constraint_violation: Neo4jOperationFailed, |
| 77 | + illegal_token_name: Neo4jOperationFailed, |
| 78 | + index_already_exists: Neo4jOperationFailed, |
| 79 | + index_belongs_to_constraint: Neo4jOperationFailed, |
| 80 | + label_limit_reached: Neo4jOperationFailed, |
| 81 | + no_such_constraint: Neo4jOperationFailed, |
| 82 | + no_such_index: Neo4jOperationFailed, |
| 83 | + statement_arithmetic_error: Neo4jOperationFailed, |
| 84 | + statement_constraint_violation: Neo4jOperationFailed, |
| 85 | + entity_not_found: Neo4jOperationFailed, |
| 86 | + invalid_arguments: Neo4jOperationFailed, |
| 87 | + invalid_semantics: Neo4jOperationFailed, |
| 88 | + invalid_syntax: Neo4jOperationFailed, |
| 89 | + no_such_label: Neo4jOperationFailed, |
| 90 | + no_such_property: Neo4jOperationFailed, |
| 91 | + parameter_missing: Neo4jOperationFailed, |
| 92 | + concurrent_request: Neo4jOperationFailed, |
| 93 | + event_handler_threw_exception: Neo4jOperationFailed, |
| 94 | + transaction_invalid_type: Neo4jOperationFailed, |
| 95 | + unknown_id: Neo4jOperationFailed, |
| 96 | + database_error: Neo4jOperationFailed, |
| 97 | + constraint_creation_failure: Neo4jOperationFailed, |
| 98 | + constraint_drop_failure: Neo4jOperationFailed, |
| 99 | + index_creation_failure: Neo4jOperationFailed, |
| 100 | + index_drop_failure: Neo4jOperationFailed, |
| 101 | + schema_no_such_label: Neo4jOperationFailed, |
| 102 | + schema_no_such_property: Neo4jOperationFailed, |
| 103 | + no_such_relationship_type: Neo4jOperationFailed, |
| 104 | + no_such_schema_rule: Neo4jOperationFailed, |
| 105 | + execution_failure: Neo4jOperationFailed, |
| 106 | + could_not_begin: Neo4jOperationFailed, |
| 107 | + could_not_commit: Neo4jOperationFailed, |
| 108 | + could_not_rollback: Neo4jOperationFailed, |
| 109 | + release_locks_failed: Neo4jOperationFailed, |
| 110 | + transient_error: Neo4jOperationFailed, |
| 111 | + unknown_failure: Neo4jOperationFailed, |
| 112 | + external_resource_failure: Neo4jOperationFailed, |
| 113 | + acquire_lock_timeout: Neo4jOperationFailed, |
| 114 | + AttributeError: Neo4jOperationFailed, |
| 115 | + TypeError: Neo4jOperationFailed, |
| 116 | + NameError: Neo4jOperationFailed, |
| 117 | + RuntimeError: Neo4jOperationFailed |
| 118 | + |
| 119 | + } |
| 120 | + |
| 121 | + |
0 commit comments