From 98edcb7588869a9a0fd8cba8084bf6c5d8df83e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Saint-F=C3=A9lix?= Date: Tue, 27 Jun 2023 17:22:24 +0200 Subject: [PATCH] Add exception to core.get to handle index_not_found & document not found (#2156) * Add exception to core.get to handle index_not_found & document not found * add documentation to get exception --- output/schema/schema.json | 40 +++++++++++++++++++++++- specification/_global/get/GetResponse.ts | 10 ++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/output/schema/schema.json b/output/schema/schema.json index 3c3860ff0e..fa5d81a480 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -17342,6 +17342,44 @@ } } }, + "exceptions": [ + { + "body": { + "kind": "value", + "value": { + "items": [ + { + "generics": [ + { + "kind": "instance_of", + "type": { + "name": "TDocument", + "namespace": "_global.get" + } + } + ], + "kind": "instance_of", + "type": { + "name": "GetResult", + "namespace": "_global.get" + } + }, + { + "kind": "instance_of", + "type": { + "name": "ErrorResponseBase", + "namespace": "_types" + } + } + ], + "kind": "union_of" + } + }, + "statusCodes": [ + 404 + ] + } + ], "generics": [ { "name": "TDocument", @@ -17353,7 +17391,7 @@ "name": "Response", "namespace": "_global.get" }, - "specLocation": "_global/get/GetResponse.ts#L22-L24" + "specLocation": "_global/get/GetResponse.ts#L23-L34" }, { "attachedBehaviors": [ diff --git a/specification/_global/get/GetResponse.ts b/specification/_global/get/GetResponse.ts index fd20053d18..7a0fd0c4c8 100644 --- a/specification/_global/get/GetResponse.ts +++ b/specification/_global/get/GetResponse.ts @@ -18,7 +18,17 @@ */ import { GetResult } from '@global/get/types' +import { ErrorResponseBase } from '@_types/Base' export class Response { body: GetResult + exceptions: [ + { + // Special case exception for 404 status code, Elasticsearch will return either: + // * index_not_found_exception as an error if the index doesn't exist + // * GetResult with only the requested _id, _index properties and found as a false boolean + statusCodes: [404] + body: GetResult | ErrorResponseBase + } + ] }