1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

feat: Improve formatting error messages from apiKube

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-04-20 15:49:58 -04:00
parent bf6af58d80
commit 3439472065

View File

@ -2,6 +2,9 @@
* Copyright (c) OpenLens Authors. All rights reserved. * Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { JsonApiErrorParsed } from "../k8s-api/json-api";
export const getErrorMessage = (error: unknown): string => { export const getErrorMessage = (error: unknown): string => {
if (typeof error === "string") { if (typeof error === "string") {
return error; return error;
@ -11,5 +14,9 @@ export const getErrorMessage = (error: unknown): string => {
return error.message; return error.message;
} }
if (error instanceof JsonApiErrorParsed) {
return error.toString();
}
return JSON.stringify(error); return JSON.stringify(error);
}; };