feat(editor): Improve errors in output panel (#8644)

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Giulio Andreini
2024-03-07 17:08:01 +01:00
committed by GitHub
parent 6e2aa405fc
commit 5301323906
38 changed files with 772 additions and 287 deletions

View File

@@ -57,31 +57,13 @@ export async function googleApiRequest(
);
}
} catch (error) {
if (error instanceof NodeApiError) throw error;
if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') {
error.statusCode = '401';
}
const apiError = new NodeApiError(
this.getNode(),
{
reason: error.error,
} as JsonObject,
{ httpCode: String(error.statusCode) },
);
if (
apiError.message &&
apiError.description &&
(apiError.message.toLowerCase().includes('bad request') ||
apiError.message.toLowerCase().includes('forbidden') ||
apiError.message.toUpperCase().includes('UNKNOWN ERROR'))
) {
const message = apiError.message;
apiError.message = apiError.description;
apiError.description = message;
}
throw apiError;
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}