From 112ebf0e454d0e156968e49089f2bccbbd474220 Mon Sep 17 00:00:00 2001 From: Golo Roden Date: Tue, 10 Nov 2026 15:47:35 +0100 Subject: [PATCH] feat: Add constants to ErrorCode for the ten error codes that EventSourcingDB 1.3 adds. EventSourcingDB 1.3 reports subject-too-long, subject-too-deep, event-schema-too-complex, backup-ahead-of-clock, import-ahead-of-clock, import-malformed, import-unreadable, query-too-deep, query-too-long, and file-unreadable, for which ErrorCode had no constant, so a caller could not use them in a switch over its constants. The list of the server's codes that ErrorCodeTest reads now holds them as well, and the constants follow its order, as the existing ones do. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FzFci8JLiwwE7sMHrJAV53 --- .../eventsourcingdb/ErrorCode.java | 30 +++++++++++++++++++ .../eventsourcingdb/server-error-slugs.txt | 10 +++++++ 2 files changed, 40 insertions(+) diff --git a/eventsourcingdb/src/main/java/io/thenativeweb/eventsourcingdb/ErrorCode.java b/eventsourcingdb/src/main/java/io/thenativeweb/eventsourcingdb/ErrorCode.java index b9191f9..dfb32c0 100644 --- a/eventsourcingdb/src/main/java/io/thenativeweb/eventsourcingdb/ErrorCode.java +++ b/eventsourcingdb/src/main/java/io/thenativeweb/eventsourcingdb/ErrorCode.java @@ -31,6 +31,12 @@ public final class ErrorCode { /** The code {@code subject-malformed}: a subject is malformed. */ public static final String SUBJECT_MALFORMED = BASE_URL + "subject-malformed"; + /** The code {@code subject-too-long}: a subject is longer than the server accepts. */ + public static final String SUBJECT_TOO_LONG = BASE_URL + "subject-too-long"; + + /** The code {@code subject-too-deep}: a subject has more segments than the server accepts. */ + public static final String SUBJECT_TOO_DEEP = BASE_URL + "subject-too-deep"; + /** The code {@code order-unknown}: the order of a read is neither chronological nor antichronological. */ public static final String ORDER_UNKNOWN = BASE_URL + "order-unknown"; @@ -118,6 +124,9 @@ public final class ErrorCode { /** The code {@code event-schema-not-object}: a schema does not describe an object. */ public static final String EVENT_SCHEMA_NOT_OBJECT = BASE_URL + "event-schema-not-object"; + /** The code {@code event-schema-too-complex}: a schema is too complex to validate against, e.g. because it refers back to a part of itself. */ + public static final String EVENT_SCHEMA_TOO_COMPLEX = BASE_URL + "event-schema-too-complex"; + /** The code {@code event-schema-already-registered}: a schema is already registered for the event type. */ public static final String EVENT_SCHEMA_ALREADY_REGISTERED = BASE_URL + "event-schema-already-registered"; @@ -175,6 +184,18 @@ public final class ErrorCode { /** The code {@code backup-unreadable}: a backup to restore could not be read to its end. */ public static final String BACKUP_UNREADABLE = BASE_URL + "backup-unreadable"; + /** The code {@code backup-ahead-of-clock}: an event of a backup to restore lies too far beyond the clock of the server. */ + public static final String BACKUP_AHEAD_OF_CLOCK = BASE_URL + "backup-ahead-of-clock"; + + /** The code {@code import-ahead-of-clock}: an event to import lies too far beyond the clock of the server. */ + public static final String IMPORT_AHEAD_OF_CLOCK = BASE_URL + "import-ahead-of-clock"; + + /** The code {@code import-malformed}: an event to import is malformed. */ + public static final String IMPORT_MALFORMED = BASE_URL + "import-malformed"; + + /** The code {@code import-unreadable}: the events to import could not be read to their end. */ + public static final String IMPORT_UNREADABLE = BASE_URL + "import-unreadable"; + /** The code {@code event-too-large}: an event exceeds the size the server accepts. */ public static final String EVENT_TOO_LARGE = BASE_URL + "event-too-large"; @@ -187,6 +208,12 @@ public final class ErrorCode { /** The code {@code query-malformed}: an EventQL query is malformed. */ public static final String QUERY_MALFORMED = BASE_URL + "query-malformed"; + /** The code {@code query-too-deep}: an EventQL query nests deeper, or chains more operands, than the server accepts. */ + public static final String QUERY_TOO_DEEP = BASE_URL + "query-too-deep"; + + /** The code {@code query-too-long}: the EventQL query of a precondition is longer than the server accepts. */ + public static final String QUERY_TOO_LONG = BASE_URL + "query-too-long"; + /** The code {@code query-unevaluable}: an EventQL query can not be evaluated. */ public static final String QUERY_UNEVALUABLE = BASE_URL + "query-unevaluable"; @@ -217,5 +244,8 @@ public final class ErrorCode { /** The code {@code server-shutting-down}: the server is shutting down. */ public static final String SERVER_SHUTTING_DOWN = BASE_URL + "server-shutting-down"; + /** The code {@code file-unreadable}: a file of the store can not be read. */ + public static final String FILE_UNREADABLE = BASE_URL + "file-unreadable"; + private ErrorCode() {} } diff --git a/eventsourcingdb/src/test/resources/io/thenativeweb/eventsourcingdb/server-error-slugs.txt b/eventsourcingdb/src/test/resources/io/thenativeweb/eventsourcingdb/server-error-slugs.txt index 53c1af8..d376504 100644 --- a/eventsourcingdb/src/test/resources/io/thenativeweb/eventsourcingdb/server-error-slugs.txt +++ b/eventsourcingdb/src/test/resources/io/thenativeweb/eventsourcingdb/server-error-slugs.txt @@ -6,6 +6,8 @@ const ( SlugSubjectMissing = "subject-missing" SlugSubjectMalformed = "subject-malformed" + SlugSubjectTooLong = "subject-too-long" + SlugSubjectTooDeep = "subject-too-deep" SlugOrderUnknown = "order-unknown" SlugEventIDMissing = "event-id-missing" SlugEventIDMalformed = "event-id-malformed" @@ -35,6 +37,7 @@ const ( SlugEventSchemaMissing = "event-schema-missing" SlugEventSchemaMalformed = "event-schema-malformed" SlugEventSchemaNotObject = "event-schema-not-object" + SlugEventSchemaTooComplex = "event-schema-too-complex" SlugEventSchemaAlreadyRegistered = "event-schema-already-registered" SlugLastAuditedEventMissing = "last-audited-event-missing" SlugLastAuditedEventMismatched = "last-audited-event-mismatched" @@ -54,10 +57,16 @@ const ( SlugBackupIncrementDisconnected = "backup-increment-disconnected" SlugBackupFailed = "backup-failed" SlugBackupUnreadable = "backup-unreadable" + SlugBackupAheadOfClock = "backup-ahead-of-clock" + SlugImportAheadOfClock = "import-ahead-of-clock" + SlugImportMalformed = "import-malformed" + SlugImportUnreadable = "import-unreadable" SlugEventTooLarge = "event-too-large" SlugDataMalformed = "data-malformed" SlugQueryMissing = "query-missing" SlugQueryMalformed = "query-malformed" + SlugQueryTooDeep = "query-too-deep" + SlugQueryTooLong = "query-too-long" SlugQueryUnevaluable = "query-unevaluable" SlugQueryNotBoolean = "query-not-boolean" SlugPreconditionViolated = "precondition-violated" @@ -68,4 +77,5 @@ const ( SlugStoreFailed = "store-failed" SlugIndexesRebuilding = "indexes-rebuilding" SlugServerShuttingDown = "server-shutting-down" + SlugFileUnreadable = "file-unreadable" )