From dbecbabf5417fcf7bd5365e83f11d859033f4469 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Mon, 30 Nov 2026 07:48:37 +0900 Subject: [PATCH] Error codes: name each engine subclass of a listed exception, or record why it stays unknown The table compares Java class names exactly, so a subclass of a listed class came out as unknown. Rows now name the subclasses with a hint that fits, and a test reads the class files of the wheel's jars and fails on an engine subclass that has neither a row nor a recorded reason. --- docs/modules/ROOT/pages/how-to/errors.adoc | 48 +++- src/arcadedb/exceptions.py | 84 ++++++- tests/conftest.py | 1 + tests/test_error_codes_parity.py | 22 ++ tests/test_error_codes_subclasses.py | 244 +++++++++++++++++++++ tests/test_error_codes_table.py | 115 ++++++++++ 6 files changed, 507 insertions(+), 7 deletions(-) create mode 100644 tests/test_error_codes_subclasses.py diff --git a/docs/modules/ROOT/pages/how-to/errors.adoc b/docs/modules/ROOT/pages/how-to/errors.adoc index 92ba75b..9b3d641 100644 --- a/docs/modules/ROOT/pages/how-to/errors.adoc +++ b/docs/modules/ROOT/pages/how-to/errors.adoc @@ -83,7 +83,7 @@ A code that the table does not know is not an empty answer: `e.code` is `unknown == The codes -One row for each code. A row with more than one engine exception matches any of them. The engine exception is matched by its Java class name. A failure that the Python layer raises itself, or that one package words differently, is matched by its text, after the rows that match a class. The first row that matches decides. +Each row gives one hint, and a code that has more than one cause has a row for each. A row with more than one engine exception matches any of them. The engine exception is matched by its Java class name, exactly: a subclass of a listed class is named in a row of its own, or stays `unknown` for a reason that `tests/test_error_codes_subclasses.py` records. A failure that the Python layer raises itself, or that one package words differently, is matched by its text, after the rows that match a class. The first row that matches decides. [cols="2,2,3,5"] |=== @@ -116,7 +116,7 @@ One row for each code. A row with more than one engine exception matches any of | `database_exists` | `DatabaseExistsError` -| `DatabaseOperationException` +| `DatabaseOperationException`, `DatabaseAlreadyExistsException` | A database already exists at this path: open it with `open_database(path)`, or choose another path. | `database_not_found` @@ -129,6 +129,11 @@ One row for each code. A row with more than one engine exception matches any of | `DatabaseIsClosedException` | The database was closed: open it again with `open_database(path)`, and read what you need from a result before you close the database. +| `database_closed` +| `DatabaseClosedError` +| `DatabaseIsReopeningException` +| The database is being reopened (a replica installing a snapshot, for example): wait a moment, then open it again and repeat the call. + | `database_read_only` | `ArcadeDBError` | `DatabaseIsReadOnlyException` @@ -139,6 +144,16 @@ One row for each code. A row with more than one engine exception matches any of | `CommandSQLParsingException`, `CommandParsingException` | The statement does not parse: fix the token that the message points at (line and column), and check the keywords against the ArcadeDB SQL or openCypher syntax. +| `syntax_error` +| `QuerySyntaxError` +| `CommandSemanticException`, `NonBooleanPatternExpressionException` +| The statement parses but breaks a rule of the query language (an undefined variable, or a pattern where only a true or false value fits, for example): change what the message names. + +| `syntax_error` +| `QuerySyntaxError` +| `FeatureNotImplementedException` +| The engine does not support this construct: write the statement another way (the message names the construct). + | `timeout` | `QueryTimeoutError` | `TimeoutException`, `PartialResultTimeoutException` @@ -149,6 +164,16 @@ One row for each code. A row with more than one engine exception matches any of | `ConcurrentModificationException`, `LockTimeoutException`, `NeedRetryException` | Another transaction changed the same data first: run the whole transaction again, for example with `db.run_in_transaction(fn)`, which retries it. +| `conflict` +| `ConflictError` +| `RefusedBeforePublishingException`, `QuorumNotReachedException`, `ReplicationQueueFullException`, `ServerIsNotTheLeaderException`, `RetryLaterException` +| The server or its cluster cannot take the transaction now (the message says why): run the whole transaction again, on the leader node when this node is not the leader. + +| `conflict` +| `ConflictError` +| `WALVersionGapException` +| A replicated or recovered change does not follow the page version stored here, so this copy of the database may be behind or damaged: check the server log before you run the transaction again. + | `type_not_found` | `SchemaError` | `SchemaException` @@ -159,9 +184,14 @@ One row for each code. A row with more than one engine exception matches any of | `AlreadyExistsException`, `TypeAlreadyExistsException` | A type, property or index with this name already exists: choose another name, or add `IF NOT EXISTS` to the CREATE statement of a type or an index. +| `already_exists` +| `SchemaError` +| `EquivalentIndexException` +| An index or constraint on these properties exists already, perhaps under another name: use it (`SELECT FROM schema:indexes` lists the indexes), or add `IF NOT EXISTS` to the CREATE statement. + | `schema` | `SchemaError` -| `SchemaException` +| `SchemaException`, `ConstraintDropFailedException`, `IndexDropFailedException` | The schema does not allow this change: read the message, and compare it with the current schema (`SELECT FROM schema:types`). | `type_mismatch` @@ -169,11 +199,21 @@ One row for each code. A row with more than one engine exception matches any of | `IllegalArgumentException`, `TypeMismatchException` | A value does not fit the type of its property: send a value of the declared type (the message names the property and the type). +| `type_mismatch` +| `ValidationError` +| `Type$InconvertibleValueException`, `ValueOutOfRangeException`, `InvalidPropertyTypeException` +| A value cannot become the type it has to be (a wrong shape, a number out of range, or a map where a property cannot hold one): change the value that the message names. + | `validation` | `ValidationError` | `ValidationException` | A property constraint (mandatory, not null, min, max, regexp or read-only) refused the record: change the value that the message names, or change the constraint in the schema. +| `validation` +| `ValidationError` +| `RecordVetoedException` +| A listener on the database vetoed this write: change the record so that the listener accepts it, or remove the listener. + | `query_not_idempotent` | `ArcadeDBError` | `QueryNotIdempotentException` @@ -190,7 +230,7 @@ The causes without a subclass (`database_read_only`, `query_not_idempotent`, `mi == Which error to retry -`ConflictError` is the one that a retry can fix: another transaction changed the same data first. Run the whole transaction again, or let `db.run_in_transaction(fn)` do it, as described on xref:how-to/transactions.adoc[Transactions] and xref:how-to/concurrency.adoc[Concurrency, processes and crashes]. A `DuplicateKeyError` is not a conflict: the same statement fails again until the value changes. A `PartialCommitError` is a conflict that a retry must not repeat. +`ConflictError` is the one that a retry can fix: another transaction changed the same data first, or the server or its cluster could not take the transaction (the hint says which, and a WAL version gap needs a look at the server log first). Run the whole transaction again, or let `db.run_in_transaction(fn)` do it, as described on xref:how-to/transactions.adoc[Transactions] and xref:how-to/concurrency.adoc[Concurrency, processes and crashes]. A `DuplicateKeyError` is not a conflict: the same statement fails again until the value changes. A `PartialCommitError` is a conflict that a retry must not repeat. [[partial-commit]] == A block that already committed part of its work diff --git a/src/arcadedb/exceptions.py b/src/arcadedb/exceptions.py index b081a86..3815cd1 100644 --- a/src/arcadedb/exceptions.py +++ b/src/arcadedb/exceptions.py @@ -372,6 +372,7 @@ class _Rule(NamedTuple): _E = "com.arcadedb.exception." +_CYPHER = "com.arcadedb.query.opencypher.parser." _HINT_RECORD_NOT_FOUND = ( "No record has this RID: check the RID, or look the record up by a property with a query " @@ -393,6 +394,8 @@ class _Rule(NamedTuple): # The table that decides the class, the code and the hint of every error. The Java names and the texts are the ones the engine # produces, collected by running both builds (tests/test_error_codes_table.py holds a literal for every row). A row with a # ``message`` and no ``java`` is for a failure that the Python layer raises itself or that one build words differently. +# Class names are compared exactly, so a subclass of a listed class needs its own name here, or a reason to stay unknown in +# tests/test_error_codes_subclasses.py, which fails on an engine subclass that has neither (#507). _RULES = ( # first: the engine wraps this refusal in a timeout when a COMMIT RETRY block ran out of time, and the half that is committed # matters more than the deadline @@ -436,7 +439,10 @@ class _Rule(NamedTuple): "database_exists", DatabaseExistsError, "A database already exists at this path: open it with `open_database(path)`, or choose another path.", - java=(_E + "DatabaseOperationException",), + java=( + _E + "DatabaseOperationException", + "com.arcadedb.server.DatabaseAlreadyExistsException", + ), message=re.compile(r"already exists"), ), _Rule( @@ -451,6 +457,13 @@ class _Rule(NamedTuple): _HINT_DATABASE_CLOSED, java=(_E + "DatabaseIsClosedException",), ), + _Rule( + "database_closed", + DatabaseClosedError, + "The database is being reopened (a replica installing a snapshot, for example): wait a moment, then open it again " + "and repeat the call.", + java=(_E + "DatabaseIsReopeningException",), + ), _Rule( "database_read_only", ArcadeDBError, @@ -464,6 +477,22 @@ class _Rule(NamedTuple): "check the keywords against the ArcadeDB SQL or openCypher syntax.", java=(_E + "CommandSQLParsingException", _E + "CommandParsingException"), ), + _Rule( + "syntax_error", + QuerySyntaxError, + "The statement parses but breaks a rule of the query language (an undefined variable, or a pattern where only a true " + "or false value fits, for example): change what the message names.", + java=( + _E + "CommandSemanticException", + _CYPHER + "NonBooleanPatternExpressionException", + ), + ), + _Rule( + "syntax_error", + QuerySyntaxError, + "The engine does not support this construct: write the statement another way (the message names the construct).", + java=(_CYPHER + "FeatureNotImplementedException",), + ), _Rule( "timeout", QueryTimeoutError, @@ -482,6 +511,26 @@ class _Rule(NamedTuple): _E + "NeedRetryException", ), ), + _Rule( + "conflict", + ConflictError, + "The server or its cluster cannot take the transaction now (the message says why): run the whole transaction again, on " + "the leader node when this node is not the leader.", + java=( + "com.arcadedb.database.RefusedBeforePublishingException", + "com.arcadedb.network.binary.QuorumNotReachedException", + "com.arcadedb.network.binary.ReplicationQueueFullException", + "com.arcadedb.network.binary.ServerIsNotTheLeaderException", + "com.arcadedb.server.http.RetryLaterException", + ), + ), + _Rule( + "conflict", + ConflictError, + "A replicated or recovered change does not follow the page version stored here, so this copy of the database may be " + "behind or damaged: check the server log before you run the transaction again.", + java=(_E + "WALVersionGapException",), + ), _Rule( "type_not_found", SchemaError, @@ -496,11 +545,22 @@ class _Rule(NamedTuple): "`IF NOT EXISTS` to the CREATE statement of a type or an index.", java=(_E + "AlreadyExistsException", _E + "TypeAlreadyExistsException"), ), + _Rule( + "already_exists", + SchemaError, + "An index or constraint on these properties exists already, perhaps under another name: use it (`SELECT FROM " + "schema:indexes` lists the indexes), or add `IF NOT EXISTS` to the CREATE statement.", + java=(_E + "EquivalentIndexException",), + ), _Rule( "schema", SchemaError, _HINT_SCHEMA, - java=(_E + "SchemaException",), + java=( + _E + "SchemaException", + _E + "ConstraintDropFailedException", + _E + "IndexDropFailedException", + ), ), _Rule( "type_mismatch", @@ -510,6 +570,17 @@ class _Rule(NamedTuple): java=("java.lang.IllegalArgumentException", _E + "TypeMismatchException"), message=re.compile(r"Cannot convert type"), ), + _Rule( + "type_mismatch", + ValidationError, + "A value cannot become the type it has to be (a wrong shape, a number out of range, or a map where a property cannot " + "hold one): change the value that the message names.", + java=( + "com.arcadedb.schema.Type$InconvertibleValueException", + _E + "ValueOutOfRangeException", + _E + "InvalidPropertyTypeException", + ), + ), _Rule( "validation", ValidationError, @@ -517,6 +588,13 @@ class _Rule(NamedTuple): "change the value that the message names, or change the constraint in the schema.", java=(_E + "ValidationException",), ), + _Rule( + "validation", + ValidationError, + "A listener on the database vetoed this write: change the record so that the listener accepts it, or remove the " + "listener.", + java=(_E + "RecordVetoedException",), + ), _Rule( "query_not_idempotent", ArcadeDBError, @@ -579,7 +657,7 @@ def _partial_commit_error(block, conflict): """ chain = _java_chain_of(conflict) if chain: - conflicts = _RULE_OF_CODE["conflict"].java + conflicts = {n for r in _RULES if r.code == "conflict" for n in r.java} name, message = next( (link for link in chain if link[0] in conflicts), chain[-1] ) diff --git a/tests/conftest.py b/tests/conftest.py index 1a5f35d..5294090 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -147,6 +147,7 @@ "test_jvm_windows_avx512.py": "JVM arguments of Windows hosts with AVX-512", "test_jar_provenance.py": "jar fingerprint of the JVM wheel", "test_jar_closure.py": "jar closure of the JVM wheel", + "test_error_codes_subclasses.py": "the exception classes in the engine jars of the JVM wheel", "test_java_package_shadowing.py": "JPype package import hooks", "test_jpype_bare_exceptions.py": "the installed JPype of the JVM wheel", "test_wheel_platform_tag.py": "JVM wheel tag", diff --git a/tests/test_error_codes_parity.py b/tests/test_error_codes_parity.py index a4ee57d..65ccfc9 100644 --- a/tests/test_error_codes_parity.py +++ b/tests/test_error_codes_parity.py @@ -292,6 +292,15 @@ def unknown_property_type(db): db.command("sql", "CREATE PROPERTY T.z FOOBAR") +def undefined_cypher_variable(db): + db.query("opencypher", "MATCH (n:V) RETURN nothere").to_list() + + +def list_for_an_integer(db): + with db.transaction(): + db.command("sql", "INSERT INTO T SET id = [1, 2]") + + def division_by_zero(db): db.query("sql", "SELECT 1/0 AS x").to_list() @@ -522,6 +531,19 @@ def unknown_function(db): "missing_parameter", E + "CommandParameterMissingException", ), + # a subclass of a listed class has its own row (#507) + ( + on_a_database(undefined_cypher_variable), + "QuerySyntaxError", + "syntax_error", + E + "CommandSemanticException", + ), + ( + on_a_database(list_for_an_integer), + "ValidationError", + "type_mismatch", + "com.arcadedb.schema.Type$InconvertibleValueException", + ), # failures that the table does not know stay ArcadeDBError with the code unknown, with the same text as before ( on_a_database(unknown_query_language), diff --git a/tests/test_error_codes_subclasses.py b/tests/test_error_codes_subclasses.py new file mode 100644 index 0000000..1fb9a42 --- /dev/null +++ b/tests/test_error_codes_subclasses.py @@ -0,0 +1,244 @@ +"""Every engine subclass of a class in the table of error codes has a decision (ArcadeData/arcadedb-python#507). + +``arcadedb.exceptions._RULES`` compares Java class names exactly, so a subclass of a listed class comes out as ``unknown`` +unless a row names it. This test reads the class files of the jars in the wheel, finds every engine class below a listed one, +and asks for one of two decisions: a row of the table names the class, or ``STAYS_UNKNOWN`` below says why not. A new engine +that adds such a class fails here until somebody decides. + +An anonymous class (``Outer$2``) is left out: its number moves with the engine source, so a table cannot name it. + +The jars are in the JVM wheel only, and both builds share the table, so this file does not run on the native build. The live +failures below need engine 26.12.1; the ones that both engines give are in ``test_error_codes_parity.py``. +""" + +import re +import struct +import zipfile +from pathlib import Path + +import pytest + +import arcadedb +from arcadedb import ArcadeDBError, exceptions +from arcadedb.jvm import get_jar_path, start_jvm + +E = "com.arcadedb.exception." + +_CLUSTER = "raised between the servers of a cluster or by the Java remote client, which neither package wraps" +_TRANSACTION = "TransactionException has a code for two of its messages only, and neither is what this one says" +_DATABASE_OPERATION = "DatabaseOperationException has a code for one of its messages only, and this is not that failure" +_ILLEGAL_ARGUMENT = ( + "IllegalArgumentException has a code for a failed type conversion only" +) +_WIRE = "raised inside a wire protocol or HTTP handler of the server, whose client gets it over the network" + +# engine class -> why it keeps the code "unknown" +STAYS_UNKNOWN = { + "com.arcadedb.engine.LocalBucket$CommittedReadInMotionException": "private to the engine, which catches it itself", + E + "BrokenChunkChainException": _DATABASE_OPERATION + " (a corrupt record)", + E + "DatabaseNotAvailableException": _DATABASE_OPERATION, + E + + "GraphBatchInProgressException": _DATABASE_OPERATION + + " (a second graph batch)", + E + + "TransactionCommittedRemotelyException": _TRANSACTION + + " (it is committed: no retry)", + E + + "TransactionOutcomeUnknownException": _TRANSACTION + + " (check what landed: no retry)", + "com.arcadedb.network.binary.ReplicatedEntryTooLargeException": _TRANSACTION, + "com.arcadedb.server.http.HttpSessionException": _WIRE, + "com.arcadedb.server.http.HttpSessionEndedException": _WIRE, + "com.arcadedb.remote.RemoteIntermediaryRefusalException": _CLUSTER + + " (resending may apply a write twice)", + "com.arcadedb.postgres.PostgresCopyStatement$CopyException": _WIRE, + E + + "ProcedureCallFailedException": _ILLEGAL_ARGUMENT + + " (the caller's own guard fired)", + "com.arcadedb.mcp.MCPToolArgumentException": _WIRE, + "com.arcadedb.server.BackupRefusedException": _ILLEGAL_ARGUMENT, + "com.arcadedb.server.ServerSettingRefusedException": _ILLEGAL_ARGUMENT, + "com.arcadedb.server.http.RequestRefusedBeforeExecutionException": _WIRE, + "com.arcadedb.server.http.handler.batch.MalformedBatchRecordException": _WIRE, +} + + +def _names(data): + """``(class name, superclass name or None)`` of a class file (JVMS 4.1 and 4.4).""" + count = struct.unpack_from(">H", data, 8)[0] + pool, index, at = {}, 1, 10 + while index < count: + tag = data[at] + at += 1 + if tag == 1: # Utf8 + size = struct.unpack_from(">H", data, at)[0] + pool[index] = data[at + 2 : at + 2 + size] + at += 2 + size + elif tag in (7, 8, 16, 19, 20): # Class and the other one-index entries + pool[index] = struct.unpack_from(">H", data, at)[0] + at += 2 + elif tag == 15: # MethodHandle + at += 3 + elif tag in (3, 4, 9, 10, 11, 12, 17, 18): + at += 4 + elif tag in (5, 6): # Long and Double take two slots + at += 8 + index += 1 + else: + raise ValueError(f"unknown constant pool tag {tag}") + index += 1 + this, parent = struct.unpack_from(">HH", data, at + 2) + + def name(entry): + return pool[pool[entry]].decode().replace("/", ".") if entry else None + + return name(this), name(parent) + + +@pytest.fixture(scope="module") +def parents(): + """``{engine class: its superclass}`` of every ``com.arcadedb`` class in the jars of the wheel.""" + found = {} + for jar in sorted(Path(get_jar_path()).glob("*.jar")): + with zipfile.ZipFile(jar) as archive: + for entry in archive.namelist(): + if entry.startswith("com/arcadedb/") and entry.endswith(".class"): + name, parent = _names(archive.read(entry)) + found[name] = parent + return found + + +def _listed(): + return {name for rule in exceptions._RULES for name in rule.java} + + +def _ancestors(name, parents): + """The superclasses of an engine class, nearest first: from the jars while they are engine classes, then from the JVM.""" + parent = parents[name] + while parent in parents: + yield parent + parent = parents[parent] + if parent and parent.startswith("java."): + import jpype + + start_jvm() + java_class = jpype.JClass(parent).class_ + while java_class is not None: + yield str(java_class.getName()) + java_class = java_class.getSuperclass() + + +def _subclasses_of_listed(parents): + listed = _listed() + return sorted( + name + for name in parents + if not re.search(r"\$\d+$", name) + and any(ancestor in listed for ancestor in _ancestors(name, parents)) + ) + + +def test_the_reader_of_the_jars_finds_the_subclasses(parents): + """The check below would pass on an empty list, so the list is checked first.""" + found = _subclasses_of_listed(parents) + for name in ( + E + "CommandSemanticException", # a direct subclass of a listed class + E + "WALVersionGapException", + E + "ValueOutOfRangeException", # below a listed JDK class + ): + assert name in found + assert ( + parents[E + "WALVersionGapException"] == E + "ConcurrentModificationException" + ) + + +def test_every_subclass_of_a_listed_class_has_a_decision(parents): + undecided = { + name: parents[name] + for name in _subclasses_of_listed(parents) + if name not in _listed() and name not in STAYS_UNKNOWN + } + assert not undecided, ( + "name each class in a row of arcadedb.exceptions._RULES (and in how-to/errors.adoc), or give it a reason in " + f"STAYS_UNKNOWN (class: superclass): {undecided}" + ) + + +def test_no_class_is_both_in_the_table_and_left_unknown(): + assert not _listed() & set(STAYS_UNKNOWN) + + +# ------------------------------------------------------------------------------------- live failures that need 26.12.1 + + +def pattern_outside_a_boolean(db): + db.query("opencypher", "MATCH (p:V) RETURN size((p)-->()) AS n").to_list() + + +def equivalent_index_under_another_name(db): + db.command("sql", "CREATE INDEX first ON T (id) UNIQUE") + db.command("sql", "CREATE INDEX second ON T (id) UNIQUE") + + +def drop_a_missing_constraint(db): + db.command("opencypher", "DROP CONSTRAINT nope") + + +def drop_a_missing_cypher_index(db): + db.command("opencypher", "DROP INDEX nope") + + +@pytest.mark.parametrize( + "scenario, class_name, code, cause", + [ + ( + pattern_outside_a_boolean, + "QuerySyntaxError", + "syntax_error", + "com.arcadedb.query.opencypher.parser.NonBooleanPatternExpressionException", + ), + ( + equivalent_index_under_another_name, + "SchemaError", + "already_exists", + E + "EquivalentIndexException", + ), + ( + drop_a_missing_constraint, + "SchemaError", + "schema", + E + "ConstraintDropFailedException", + ), + ( + drop_a_missing_cypher_index, + "SchemaError", + "schema", + E + "IndexDropFailedException", + ), + ], + ids=lambda value: getattr(value, "__name__", ""), +) +def test_a_new_failure_of_26_12_1_has_its_code( + tmp_path, scenario, class_name, code, cause +): + with arcadedb.create_database(str(tmp_path / "db")) as db: + db.command("sql", "CREATE VERTEX TYPE V") + db.command("sql", "CREATE DOCUMENT TYPE T") + db.command("sql", "CREATE PROPERTY T.id INTEGER") + with pytest.raises(ArcadeDBError) as caught: + scenario(db) + error = caught.value + assert (type(error).__name__, error.code, error.cause) == (class_name, code, cause) + assert error.hint and str(error).startswith(f"[{code}] {error.hint} ") + + +def test_the_hint_for_an_equivalent_index_does_not_say_to_choose_another_name(tmp_path): + """A name is not what conflicts there: the same properties are indexed already. ``IF NOT EXISTS`` accepts that.""" + with arcadedb.create_database(str(tmp_path / "db")) as db: + db.command("sql", "CREATE DOCUMENT TYPE T") + db.command("sql", "CREATE PROPERTY T.id INTEGER") + db.command("sql", "CREATE INDEX first ON T (id) UNIQUE") + with pytest.raises(arcadedb.SchemaError) as caught: + db.command("sql", "CREATE INDEX second ON T (id) UNIQUE") + assert "choose another name" not in caught.value.hint + db.command("sql", "CREATE INDEX second IF NOT EXISTS ON T (id) UNIQUE") diff --git a/tests/test_error_codes_table.py b/tests/test_error_codes_table.py index e9c3d90..58b7c21 100644 --- a/tests/test_error_codes_table.py +++ b/tests/test_error_codes_table.py @@ -352,6 +352,121 @@ ] +# The subclasses of listed classes that a row names (#507): (Java class, message, Python class, code). The table compares names +# exactly, so each is a literal of its own; tests/test_error_codes_subclasses.py finds a subclass that has no decision. +_SUBCLASSES = [ + ( + E + "DatabaseIsReopeningException", + "reopening", + "DatabaseClosedError", + "database_closed", + ), + ( + E + "CommandSemanticException", + "Variable `x` not defined", + "QuerySyntaxError", + "syntax_error", + ), + ( + "com.arcadedb.query.opencypher.parser.NonBooleanPatternExpressionException", + "UnexpectedSyntax: pattern", + "QuerySyntaxError", + "syntax_error", + ), + ( + "com.arcadedb.query.opencypher.parser.FeatureNotImplementedException", + "FeatureNotImplemented: x", + "QuerySyntaxError", + "syntax_error", + ), + ( + "com.arcadedb.database.RefusedBeforePublishingException", + "refused", + "ConflictError", + "conflict", + ), + ( + "com.arcadedb.network.binary.QuorumNotReachedException", + "no quorum", + "ConflictError", + "conflict", + ), + ( + "com.arcadedb.network.binary.ReplicationQueueFullException", + "queue full", + "ConflictError", + "conflict", + ), + ( + "com.arcadedb.network.binary.ServerIsNotTheLeaderException", + "not the leader", + "ConflictError", + "conflict", + ), + ( + "com.arcadedb.server.http.RetryLaterException", + "retry later", + "ConflictError", + "conflict", + ), + (E + "WALVersionGapException", "version gap", "ConflictError", "conflict"), + ( + E + "EquivalentIndexException", + "Found the existing index", + "SchemaError", + "already_exists", + ), + ( + E + "ConstraintDropFailedException", + "no such constraint", + "SchemaError", + "schema", + ), + (E + "IndexDropFailedException", "no such index", "SchemaError", "schema"), + ( + "com.arcadedb.schema.Type$InconvertibleValueException", + "cannot be converted to type INTEGER", + "ValidationError", + "type_mismatch", + ), + ( + E + "ValueOutOfRangeException", + "out of range for type FLOAT", + "ValidationError", + "type_mismatch", + ), + ( + E + "InvalidPropertyTypeException", + "Property values cannot be maps", + "ValidationError", + "type_mismatch", + ), + ( + E + "RecordVetoedException", + "a listener vetoed it", + "ValidationError", + "validation", + ), + ( + "com.arcadedb.server.DatabaseAlreadyExistsException", + "Database 'db' already exists", + "DatabaseExistsError", + "database_exists", + ), +] +CASES += [ + ( + name.rsplit(".", 1)[-1], + f"Command failed: {name}: {message}", + [(name, message)], + class_name, + code, + name, + ) + for name, message, class_name, code in _SUBCLASSES +] + + def _ids(cases): return [case[0] for case in cases]