From 995f03ab83da4711039ca4de2b7c74afbe36e219 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Mon, 16 Mar 2020 19:44:14 +0000 Subject: [PATCH] [ML] Add errors.ts --- x-pack/plugins/ml/common/types/errors.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 x-pack/plugins/ml/common/types/errors.ts diff --git a/x-pack/plugins/ml/common/types/errors.ts b/x-pack/plugins/ml/common/types/errors.ts new file mode 100644 index 0000000000000..63e222490082b --- /dev/null +++ b/x-pack/plugins/ml/common/types/errors.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export interface ErrorResponse { + body: { + statusCode: number; + error: string; + message: string; + }; + name: string; +} + +export function isErrorResponse(arg: any): arg is ErrorResponse { + return arg?.body?.error !== undefined && arg?.body?.message !== undefined; +}