From 9962260d890c77a71dd763df487422958164a6aa Mon Sep 17 00:00:00 2001 From: Ilja Pavlovs Date: Mon, 15 Jun 2026 13:44:24 +0300 Subject: [PATCH] BCM-1732: add support for structured not found error code --- api/openapi.yaml | 27 +++++++++++++++++++++++++-- client/client.gen.go | 15 +++++++++++++++ ginserver/ginserver.gen.go | 15 +++++++++++++++ stdserver/stdserver.gen.go | 15 +++++++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index d36431c..e3ac287 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -1074,12 +1074,16 @@ paths: $ref: "#/components/schemas/ApplicationError" example: {type: "VALIDATION_ERROR", message: "Invalid request data."} "404": - description: Channel not found + description: Channel or wallet not found content: application/json: schema: $ref: "#/components/schemas/ApplicationError" - example: {type: "NOT_FOUND", message: "The requested channel was not found."} + examples: + channelNotFound: + value: {type: "NOT_FOUND", code: "CHANNEL_NOT_FOUND", message: "channel with ID abc not found"} + walletNotFound: + value: {type: "NOT_FOUND", code: "WALLET_NOT_FOUND", message: "wallet with address 0x742d35Cc6634C0532925a3b844Bc454e4438f44e and chain_selector 16015286601757825753 not found"} "500": description: Internal server error content: @@ -2067,6 +2071,22 @@ components: - to - value - data + ApplicationErrorCode: + type: string + description: Machine-readable error code for NOT_FOUND responses. + enum: + - CHANNEL_NOT_FOUND + - WALLET_NOT_FOUND + - OPERATION_NOT_FOUND + - WATCHER_NOT_FOUND + - QUERY_NOT_FOUND + x-enum-varnames: + - ApplicationErrorCodeChannelNotFound + - ApplicationErrorCodeWalletNotFound + - ApplicationErrorCodeOperationNotFound + - ApplicationErrorCodeWatcherNotFound + - ApplicationErrorCodeQueryNotFound + example: "WALLET_NOT_FOUND" ApplicationError: description: Standard error response body. type: object @@ -2080,6 +2100,9 @@ components: - "VALIDATION_ERROR" - "CONFLICT" - "INTERNAL_ERROR" + code: + $ref: "#/components/schemas/ApplicationErrorCode" + description: Machine-readable error code. Present on NOT_FOUND responses for tenant resources. message: type: string description: Error message describing the issue diff --git a/client/client.gen.go b/client/client.gen.go index 5f58db0..d098052 100644 --- a/client/client.gen.go +++ b/client/client.gen.go @@ -30,6 +30,15 @@ const ( VALIDATIONERROR ApplicationErrorType = "VALIDATION_ERROR" ) +// Defines values for ApplicationErrorCode. +const ( + ApplicationErrorCodeChannelNotFound ApplicationErrorCode = "CHANNEL_NOT_FOUND" + ApplicationErrorCodeOperationNotFound ApplicationErrorCode = "OPERATION_NOT_FOUND" + ApplicationErrorCodeQueryNotFound ApplicationErrorCode = "QUERY_NOT_FOUND" + ApplicationErrorCodeWalletNotFound ApplicationErrorCode = "WALLET_NOT_FOUND" + ApplicationErrorCodeWatcherNotFound ApplicationErrorCode = "WATCHER_NOT_FOUND" +) + // Defines values for BlockNumberBlockSelectionType. const ( BlockNumberBlockSelectionTypeBlockNumber BlockNumberBlockSelectionType = "block_number" @@ -143,6 +152,9 @@ const ( // ApplicationError Standard error response body. type ApplicationError struct { + // Code Machine-readable error code for NOT_FOUND responses. + Code *ApplicationErrorCode `json:"code,omitempty"` + // Message Error message describing the issue Message string `json:"message"` @@ -153,6 +165,9 @@ type ApplicationError struct { // ApplicationErrorType Error type type ApplicationErrorType string +// ApplicationErrorCode Machine-readable error code for NOT_FOUND responses. +type ApplicationErrorCode string + // BlockNumberBlockSelection defines model for BlockNumberBlockSelection. type BlockNumberBlockSelection struct { // BlockNumber Decimal uint64 block number. diff --git a/ginserver/ginserver.gen.go b/ginserver/ginserver.gen.go index 2503e42..ed3e2e3 100644 --- a/ginserver/ginserver.gen.go +++ b/ginserver/ginserver.gen.go @@ -28,6 +28,15 @@ const ( VALIDATIONERROR ApplicationErrorType = "VALIDATION_ERROR" ) +// Defines values for ApplicationErrorCode. +const ( + ApplicationErrorCodeChannelNotFound ApplicationErrorCode = "CHANNEL_NOT_FOUND" + ApplicationErrorCodeOperationNotFound ApplicationErrorCode = "OPERATION_NOT_FOUND" + ApplicationErrorCodeQueryNotFound ApplicationErrorCode = "QUERY_NOT_FOUND" + ApplicationErrorCodeWalletNotFound ApplicationErrorCode = "WALLET_NOT_FOUND" + ApplicationErrorCodeWatcherNotFound ApplicationErrorCode = "WATCHER_NOT_FOUND" +) + // Defines values for BlockNumberBlockSelectionType. const ( BlockNumberBlockSelectionTypeBlockNumber BlockNumberBlockSelectionType = "block_number" @@ -141,6 +150,9 @@ const ( // ApplicationError Standard error response body. type ApplicationError struct { + // Code Machine-readable error code for NOT_FOUND responses. + Code *ApplicationErrorCode `json:"code,omitempty"` + // Message Error message describing the issue Message string `json:"message"` @@ -151,6 +163,9 @@ type ApplicationError struct { // ApplicationErrorType Error type type ApplicationErrorType string +// ApplicationErrorCode Machine-readable error code for NOT_FOUND responses. +type ApplicationErrorCode string + // BlockNumberBlockSelection defines model for BlockNumberBlockSelection. type BlockNumberBlockSelection struct { // BlockNumber Decimal uint64 block number. diff --git a/stdserver/stdserver.gen.go b/stdserver/stdserver.gen.go index d735454..1074bb4 100644 --- a/stdserver/stdserver.gen.go +++ b/stdserver/stdserver.gen.go @@ -28,6 +28,15 @@ const ( VALIDATIONERROR ApplicationErrorType = "VALIDATION_ERROR" ) +// Defines values for ApplicationErrorCode. +const ( + ApplicationErrorCodeChannelNotFound ApplicationErrorCode = "CHANNEL_NOT_FOUND" + ApplicationErrorCodeOperationNotFound ApplicationErrorCode = "OPERATION_NOT_FOUND" + ApplicationErrorCodeQueryNotFound ApplicationErrorCode = "QUERY_NOT_FOUND" + ApplicationErrorCodeWalletNotFound ApplicationErrorCode = "WALLET_NOT_FOUND" + ApplicationErrorCodeWatcherNotFound ApplicationErrorCode = "WATCHER_NOT_FOUND" +) + // Defines values for BlockNumberBlockSelectionType. const ( BlockNumberBlockSelectionTypeBlockNumber BlockNumberBlockSelectionType = "block_number" @@ -141,6 +150,9 @@ const ( // ApplicationError Standard error response body. type ApplicationError struct { + // Code Machine-readable error code for NOT_FOUND responses. + Code *ApplicationErrorCode `json:"code,omitempty"` + // Message Error message describing the issue Message string `json:"message"` @@ -151,6 +163,9 @@ type ApplicationError struct { // ApplicationErrorType Error type type ApplicationErrorType string +// ApplicationErrorCode Machine-readable error code for NOT_FOUND responses. +type ApplicationErrorCode string + // BlockNumberBlockSelection defines model for BlockNumberBlockSelection. type BlockNumberBlockSelection struct { // BlockNumber Decimal uint64 block number.