File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
packages/gitbook/src/app/(global)/~gitbook/revalidate Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " gitbook " : patch
3
+ ---
4
+
5
+ Better error handling in cache revalidation.
Original file line number Diff line number Diff line change @@ -25,10 +25,23 @@ export async function POST(req: NextRequest) {
25
25
) ;
26
26
}
27
27
28
- const result = await revalidateTags ( json . tags ) ;
28
+ try {
29
+ const result = await revalidateTags ( json . tags ) ;
30
+ return NextResponse . json ( {
31
+ success : true ,
32
+ stats : result . stats ,
33
+ } ) ;
34
+ } catch ( err : unknown ) {
35
+ const message = [
36
+ err instanceof Error ? err . name : 'Internal Server Error' ,
37
+ ...( err instanceof Error && err . message ? [ err . message ] : [ ] ) ,
38
+ ...( err instanceof Error && err . cause ? [ err . cause ] : [ ] ) ,
39
+ ...( err instanceof Error && err . stack ? [ err . stack ] : [ ] ) ,
40
+ ] . join ( '\n' ) ;
29
41
30
- return NextResponse . json ( {
31
- success : true ,
32
- stats : result . stats ,
33
- } ) ;
42
+ return new NextResponse ( null , {
43
+ status : 500 ,
44
+ statusText : message ,
45
+ } ) ;
46
+ }
34
47
}
You can’t perform that action at this time.
0 commit comments