Refine PPR error screening logic

This commit is contained in:
Sam Becker 2024-03-01 17:33:53 -06:00
parent ab567a456b
commit 3ad0e6d2f3

View File

@ -5,27 +5,12 @@ export const screenForPPR = <T>(
): T => {
// PPR errors, if caught, must be re-thrown in order to
// postpone rendering
if (error.sourceError?.message?.includes('ppr-caught-error')) {
console.log(
// eslint-disable-next-line max-len
sourceToLog ? `screenForPPR A: ${sourceToLog}: PPR error caught` : 'PPR error caught',
error,
);
console.log(`${sourceToLog}: throwing error.sourceError`);
throw error.sourceError;
} else if (error.message?.includes('ppr-caught-error')) {
console.log(
// eslint-disable-next-line max-len
sourceToLog ? `screenForPPR B: ${sourceToLog}: PPR error caught` : 'PPR error caught',
error,
);
console.log(`${sourceToLog}: throwing error`);
throw error;
} else if (sourceToLog) {
console.log(// eslint-disable-next-line max-len
sourceToLog ? `screenForPPR C: ${sourceToLog}: PPR error caught` : 'PPR error caught',
error
);
}
return fallback;
};