@@ -6,7 +6,7 @@ export async function getMciList(nsId) {
66
77 if ( nsId == "" ) {
88 console . log ( "Project has not set" )
9- return ;
9+ return [ ] ;
1010 }
1111
1212 var data = {
@@ -16,14 +16,26 @@ export async function getMciList(nsId) {
1616 } ;
1717
1818 var controller = "/api/" + "mc-infra-manager/" + "GetAllMci" ;
19- const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
20- controller ,
21- data
22- )
23-
24- var mciList = response . data . responseData ;
25-
26- return mciList
19+
20+ try {
21+ const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
22+ controller ,
23+ data
24+ )
25+
26+ var mciList = response . data . responseData ;
27+ return mciList || [ ] ;
28+ } catch ( error ) {
29+ // 404 에러 (데이터가 없는 경우)는 정상적인 상황이므로 빈 배열 반환
30+ if ( error . response && error . response . status === 404 ) {
31+ console . log ( "No MCI data found for namespace:" , nsId ) ;
32+ return [ ] ;
33+ }
34+
35+ // 다른 에러는 그대로 throw
36+ console . error ( "Error fetching MCI list:" , error ) ;
37+ throw error ;
38+ }
2739}
2840
2941// 받아온 project(namespace)로 MciList Id Arr GET
@@ -58,7 +70,7 @@ export async function getMciList(nsId) {
5870export async function getMci ( nsId , mciId ) {
5971 if ( nsId == "" || nsId == undefined || mciId == undefined || mciId == "" ) {
6072 console . log ( " undefined nsId: " + nsId + " mciId " + mciId ) ;
61- return ;
73+ return null ;
6274 }
6375 const data = {
6476 pathParams : {
@@ -68,21 +80,34 @@ export async function getMci(nsId, mciId) {
6880 }
6981
7082 var controller = "/api/" + "mc-infra-manager/" + "GetMci" ;
71- const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
72- controller ,
73- data
74- ) ;
75-
76- // error check를 위해 response를 return
77- return response . data
83+
84+ try {
85+ const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
86+ controller ,
87+ data
88+ ) ;
89+
90+ // error check를 위해 response를 return
91+ return response . data ;
92+ } catch ( error ) {
93+ // 404 에러 (MCI가 없는 경우)는 정상적인 상황이므로 null 반환
94+ if ( error . response && error . response . status === 404 ) {
95+ console . log ( "MCI not found:" , mciId , "in namespace:" , nsId ) ;
96+ return null ;
97+ }
98+
99+ // 다른 에러는 그대로 throw
100+ console . error ( "Error fetching MCI:" , error ) ;
101+ throw error ;
102+ }
78103}
79104
80105
81106// mci vm 단건 조회
82107export async function getMciVm ( nsId , mciId , vmId ) {
83108 if ( nsId == "" || nsId == undefined || mciId == undefined || vmId == "" || vmId == undefined || vmId == "" ) {
84109 console . log ( " undefined nsId: " + nsId , + " mciId " + mciId , ", vmId " + vmId ) ;
85- return ;
110+ return null ;
86111 }
87112 const data = {
88113 pathParams : {
@@ -93,13 +118,26 @@ export async function getMciVm(nsId, mciId, vmId) {
93118 }
94119
95120 var controller = "/api/" + "mc-infra-manager/" + "GetMciVm" ;
96- const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
97- controller ,
98- data
99- ) ;
100-
101- // error check를 위해 response를 return
102- return response . data
121+
122+ try {
123+ const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
124+ controller ,
125+ data
126+ ) ;
127+
128+ // error check를 위해 response를 return
129+ return response . data ;
130+ } catch ( error ) {
131+ // 404 에러 (VM이 없는 경우)는 정상적인 상황이므로 null 반환
132+ if ( error . response && error . response . status === 404 ) {
133+ console . log ( "VM not found:" , vmId , "in MCI:" , mciId , "namespace:" , nsId ) ;
134+ return null ;
135+ }
136+
137+ // 다른 에러는 그대로 throw
138+ console . error ( "Error fetching MCI VM:" , error ) ;
139+ throw error ;
140+ }
103141}
104142
105143// mciLifeCycle 제어 option : reboot / suspend / resume / terminate
@@ -677,7 +715,7 @@ export async function getPolicyList(nsId) {
677715
678716 if ( nsId == "" ) {
679717 console . log ( "Project has not set" )
680- return ;
718+ return [ ] ;
681719 }
682720
683721 var data = {
@@ -687,14 +725,26 @@ export async function getPolicyList(nsId) {
687725 } ;
688726
689727 var controller = "/api/" + "mc-infra-manager/" + "Getallmcipolicy" ;
690- const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
691- controller ,
692- data
693- )
694-
695- var policyList = response . data . responseData ;
696-
697- return policyList
728+
729+ try {
730+ const response = await webconsolejs [ "common/api/http" ] . commonAPIPost (
731+ controller ,
732+ data
733+ )
734+
735+ var policyList = response . data . responseData ;
736+ return policyList || [ ] ;
737+ } catch ( error ) {
738+ // 404 에러 (정책이 없는 경우)는 정상적인 상황이므로 빈 배열 반환
739+ if ( error . response && error . response . status === 404 ) {
740+ console . log ( "No policy data found for namespace:" , nsId ) ;
741+ return [ ] ;
742+ }
743+
744+ // 다른 에러는 그대로 throw
745+ console . error ( "Error fetching policy list:" , error ) ;
746+ throw error ;
747+ }
698748}
699749
700750export async function deletePolicy ( nsId , mciId ) {
0 commit comments