Hide ppr rethrow console messages

This commit is contained in:
Sam Becker 2024-04-19 00:04:06 -05:00
parent 45d3ba661f
commit dbe410384e

View File

@ -2,14 +2,19 @@ export const screenForPPR = <T>(
error: any, error: any,
fallback: T, fallback: T,
sourceToLog?: string, sourceToLog?: string,
debug?: boolean
): T => { ): T => {
// PPR errors, if caught, must be re-thrown in order to // PPR errors, if caught, must be re-thrown in order to
// postpone rendering // postpone rendering
if (error.sourceError?.message?.includes('ppr-caught-error')) { if (error.sourceError?.message?.includes('ppr-caught-error')) {
console.log(`${sourceToLog}: throwing error.sourceError`); if (debug) {
console.log(`${sourceToLog}: throwing error.sourceError`);
}
throw error.sourceError; throw error.sourceError;
} else if (error.message?.includes('ppr-caught-error')) { } else if (error.message?.includes('ppr-caught-error')) {
console.log(`${sourceToLog}: throwing error`); if (debug) {
console.log(`${sourceToLog}: throwing error`);
}
throw error; throw error;
} }
return fallback; return fallback;