File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -191,6 +191,9 @@ export const codes: Record<string, ResponseStatus> = {
191191 // The user agent requested a resource that cannot legally
192192 // be provided, such as a web page censored by a government.
193193 LEGAL_REASONS : { code : 451 , status : 'Unavailable For Legal Reasons' } ,
194+ // This status code means that the CSRF token sent by the client is incorrect
195+ // or missing. This is used to prevent Cross-Site Request Forgery attacks.
196+ PAGE_EXPIRED : { code : 419 , status : 'Page Expired' } ,
194197
195198 //------------------------------------------------------------------//
196199 // 500 Status Codes
@@ -288,6 +291,7 @@ const Status = {
288291 TOO_MANY : codes . TOO_MANY ,
289292 HEADER_TOO_LARGE : codes . HEADER_TOO_LARGE ,
290293 LEGAL_REASONS : codes . LEGAL_REASONS ,
294+ PAGE_EXPIRED : codes . PAGE_EXPIRED ,
291295
292296 //------------------------------------------------------------------//
293297 // 500 Status Codes
Original file line number Diff line number Diff line change @@ -229,4 +229,15 @@ describe('Exception Tests', () => {
229229 expect ( response . status ) . to . equal ( 'Unknown' ) ;
230230 } ) ;
231231
232+ it ( 'Should handle page expired error' , ( ) => {
233+ try {
234+ throw Exception . for ( 'Page expired' ) . withCode ( 419 ) ;
235+ } catch ( e ) {
236+ const exception = Exception . upgrade ( e as Error ) ;
237+ const response = exception . toResponse ( ) ;
238+ expect ( response . code ) . to . equal ( 419 ) ;
239+ expect ( response . status ) . to . equal ( 'Page Expired' ) ;
240+ expect ( response . error ) . to . equal ( 'Page expired' ) ;
241+ }
242+ } ) ;
232243} ) ;
You can’t perform that action at this time.
0 commit comments