@@ -682,8 +682,17 @@ async function validateESRefreshMethod (method) {
682
682
async function getProjectDefaultTerms ( projectId ) {
683
683
const token = await getM2MToken ( )
684
684
const projectUrl = `${ config . PROJECTS_API_URL } /${ projectId } `
685
- const res = await axios . get ( projectUrl , { headers : { Authorization : `Bearer ${ token } ` } } )
686
- return res . data . terms || [ ]
685
+ try {
686
+ const res = await axios . get ( projectUrl , { headers : { Authorization : `Bearer ${ token } ` } } )
687
+ return res . data . terms || [ ]
688
+ } catch ( err ) {
689
+ if ( _ . get ( err , 'response.status' ) === HttpStatus . NOT_FOUND ) {
690
+ throw new errors . BadRequestError ( `Project with id: ${ projectId } doesn't exist` )
691
+ } else {
692
+ // re-throw other error
693
+ throw err
694
+ }
695
+ }
687
696
}
688
697
689
698
/**
@@ -695,8 +704,17 @@ async function getProjectDefaultTerms (projectId) {
695
704
async function getProjectBillingAccount ( projectId ) {
696
705
const token = await getM2MToken ( )
697
706
const projectUrl = `${ config . V3_PROJECTS_API_URL } /${ projectId } `
698
- const res = await axios . get ( projectUrl , { headers : { Authorization : `Bearer ${ token } ` } } )
699
- return _ . get ( res , 'data.result.content.billingAccountIds[0]' , null )
707
+ try {
708
+ const res = await axios . get ( projectUrl , { headers : { Authorization : `Bearer ${ token } ` } } )
709
+ return _ . get ( res , 'data.result.content.billingAccountIds[0]' , null )
710
+ } catch ( err ) {
711
+ if ( _ . get ( err , 'response.status' ) === HttpStatus . NOT_FOUND ) {
712
+ throw new errors . BadRequestError ( `Project with id: ${ projectId } doesn't exist` )
713
+ } else {
714
+ // re-throw other error
715
+ throw err
716
+ }
717
+ }
700
718
}
701
719
702
720
/**
0 commit comments