mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 10:03:31 +00:00
Better error handling in revalidate v1 (#3094)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Better error handling in cache revalidation.
|
||||
@@ -25,10 +25,23 @@ export async function POST(req: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
const result = await revalidateTags(json.tags);
|
||||
try {
|
||||
const result = await revalidateTags(json.tags);
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
stats: result.stats,
|
||||
});
|
||||
} catch (err: unknown) {
|
||||
const message = [
|
||||
err instanceof Error ? err.name : 'Internal Server Error',
|
||||
...(err instanceof Error && err.message ? [err.message] : []),
|
||||
...(err instanceof Error && err.cause ? [err.cause] : []),
|
||||
...(err instanceof Error && err.stack ? [err.stack] : []),
|
||||
].join('\n');
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
stats: result.stats,
|
||||
});
|
||||
return new NextResponse(null, {
|
||||
status: 500,
|
||||
statusText: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user