@@ -682,8 +682,17 @@ async function validateESRefreshMethod (method) {
682682async function getProjectDefaultTerms ( projectId ) {
683683 const token = await getM2MToken ( )
684684 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+ }
687696}
688697
689698/**
@@ -695,8 +704,17 @@ async function getProjectDefaultTerms (projectId) {
695704async function getProjectBillingAccount ( projectId ) {
696705 const token = await getM2MToken ( )
697706 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+ }
700718}
701719
702720/**
0 commit comments