mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
Ignore all errors for rendering integration blocks (#293)
This commit is contained in:
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user