Ignore all errors for rendering integration blocks (#293)

This commit is contained in:
Samy Pessé
2024-03-18 11:08:49 +00:00
committed by GitHub
parent 5f70ed73b9
commit 66dcaf850f
2 changed files with 6 additions and 2 deletions
@@ -74,6 +74,7 @@ export async function IntegrationBlock(props: BlockProps<DocumentBlockIntegratio
const initialOutput = await ignoreAPIError(
renderIntegrationUi(block.data.integration, initialInput),
true,
);
if (!initialOutput) {
return null;
+5 -2
View File
@@ -849,12 +849,15 @@ export function userAgent(): string {
/**
* Ignore error for an API call.
*/
export async function ignoreAPIError<T>(promise: Promise<T>): Promise<T | null> {
export async function ignoreAPIError<T>(
promise: Promise<T>,
ignoreAll: boolean = false,
): Promise<T | null> {
try {
return await promise;
} catch (error) {
const code = (error as GitBookAPIError).code;
if (code >= 400 && code < 500) {
if (ignoreAll || (code >= 400 && code < 500)) {
return null;
}