Change ppr error handling
This commit is contained in:
parent
3a60d6bbf4
commit
4820aa6545
@ -3,16 +3,24 @@ export const screenForPPR = <T>(
|
|||||||
fallback: T,
|
fallback: T,
|
||||||
sourceToLog?: string,
|
sourceToLog?: string,
|
||||||
): T => {
|
): T => {
|
||||||
if (/ppr-caught-error/.test(error.message) && error.sourceError) {
|
// 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')) {
|
||||||
console.log(
|
console.log(
|
||||||
sourceToLog ? `${sourceToLog}: PPR error caught` : 'PPR error caught',
|
sourceToLog ? `${sourceToLog}: PPR error caught` : 'PPR error caught',
|
||||||
error.sourceError,
|
error.sourceError.message,
|
||||||
);
|
);
|
||||||
throw error.sourceError;
|
throw error.sourceError.message;
|
||||||
|
} else if (error.message?.includes('ppr-caught-error')) {
|
||||||
|
console.log(
|
||||||
|
sourceToLog ? `${sourceToLog}: PPR error caught` : 'PPR error caught',
|
||||||
|
error.message,
|
||||||
|
);
|
||||||
|
throw error.message;
|
||||||
} else if (sourceToLog) {
|
} else if (sourceToLog) {
|
||||||
console.error(sourceToLog, error.message);
|
console.error(sourceToLog, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fallback;
|
return fallback;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user