File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ export default async function requestAndResultsFormatter(options: OpenGraphScrap
9090 throw new Error ( '408 Request Timeout' ) ;
9191 case 410 :
9292 throw new Error ( '410 Gone' ) ;
93+ case 429 :
94+ throw new Error ( '429 Too Many Requests' ) ;
9395 case 500 :
9496 throw new Error ( '500 Internal Server Error' ) ;
9597 case 502 :
Original file line number Diff line number Diff line change @@ -505,6 +505,28 @@ describe('return ogs', function () {
505505 } ) ;
506506 } ) ;
507507
508+ it ( 'when the request sends a 429 error' , function ( ) {
509+ mockAgent . get ( 'http://www.testerror.com' )
510+ . intercept ( { path : '/' } )
511+ . reply ( 429 , {
512+ message : '429 Too Many Requests' ,
513+ code : '429' ,
514+ } ) ;
515+
516+ return ogs ( { url : 'http://www.testerror.com' } )
517+ . then ( function ( ) {
518+ expect ( '' ) . to . be . eql ( 'this should not happen' ) ;
519+ } )
520+ . catch ( function ( data ) {
521+ expect ( data . error ) . to . be . eql ( true ) ;
522+ expect ( data . result . error ) . to . eql ( '429 Too Many Requests' ) ;
523+ expect ( data . result . errorDetails . toString ( ) ) . to . eql ( 'Error: 429 Too Many Requests' ) ;
524+ expect ( data . result . success ) . to . eql ( false ) ;
525+ expect ( data . response ) . to . be . eql ( undefined ) ;
526+ expect ( data . html ) . to . be . eql ( undefined ) ;
527+ } ) ;
528+ } ) ;
529+
508530 it ( 'when the request sends a general error' , function ( ) {
509531 mockAgent . get ( 'http://www.testerror.com' )
510532 . intercept ( { path : '/' } )
You can’t perform that action at this time.
0 commit comments