feat(editor): Improve errors in output panel (#8644)
Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user