File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -879,20 +879,26 @@ async function listChallengesByMember (memberId) {
879879 // get search is paginated, we need to get all pages' data
880880 let page = 1
881881 while ( true ) {
882- const result = await axios . get ( `${ config . RESOURCES_API_URL } /${ memberId } /challenges` , {
883- headers : { Authorization : `Bearer ${ token } ` } ,
884- params : {
885- page,
886- perPage : 10000
887- }
888- } )
882+ let result = { } ;
883+ try {
884+ result = await axios . get ( `${ config . RESOURCES_API_URL } /${ memberId } /challenges` , {
885+ headers : { Authorization : `Bearer ${ token } ` } ,
886+ params : {
887+ page,
888+ perPage : 10000
889+ }
890+ } )
891+ } catch ( e ) {
892+ // only log the error but don't throw it, so the following logic can still be executed.
893+ logger . debug ( `Failed to get challenges that accessible to the memberId ${ memberId } ` , e )
894+ }
889895 const ids = result . data || [ ]
890896 if ( ids . length === 0 ) {
891897 break
892898 }
893899 allIds = allIds . concat ( ids )
894900 page += 1
895- if ( result . headers [ 'x-total-pages' ] && page > Number ( result . headers [ 'x-total-pages' ] ) ) {
901+ if ( result . headers && result . headers [ 'x-total-pages' ] && page > Number ( result . headers [ 'x-total-pages' ] ) ) {
896902 break
897903 }
898904 }
You can’t perform that action at this time.
0 commit comments