Skip to content

Commit

Permalink
server: api: rest: Show error message of the connection info
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Dec 4, 2024
1 parent 82c1aff commit 89ec840
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions server/pkg/api/rest/controller/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func doImportInfra(connID string) (*model.SavedInfraInfo, error) {
savedInfraInfo, err = dao.SavedInfraInfoRegister(savedInfraInfo)
if err != nil {
errMsg := "Error occurred while getting infra information." +
" (ConnectionID = " + connectionInfo.ID + ")"
" (ConnectionID=" + connectionInfo.ID + ", Error=" + err.Error() + ")"
logger.Println(logger.ERROR, false, errMsg)
return nil, errors.New(errMsg)
}
Expand All @@ -45,7 +45,7 @@ func doImportInfra(connID string) (*model.SavedInfraInfo, error) {
oldSavedInfraInfo.Status = "failed"
_ = dao.SavedInfraInfoUpdate(oldSavedInfraInfo)
errMsg := "Error occurred while getting infra information." +
" (ConnectionID = " + connectionInfo.ID + ")"
" (ConnectionID=" + connectionInfo.ID + ", Error=" + err.Error() + ")"
logger.Println(logger.ERROR, false, errMsg)
return nil, errors.New(errMsg)
}
Expand All @@ -55,8 +55,8 @@ func doImportInfra(connID string) (*model.SavedInfraInfo, error) {
oldSavedInfraInfo.SavedTime = time.Now()
err = dao.SavedInfraInfoUpdate(oldSavedInfraInfo)
if err != nil {
errMsg := "Error occurred while saving the infra information." +
" (ConnectionID = " + connectionInfo.ID + ")"
errMsg := "Error occurred while getting infra information." +
" (ConnectionID=" + connectionInfo.ID + ", Error=" + err.Error() + ")"
logger.Println(logger.ERROR, false, errMsg)
return nil, errors.New(errMsg)
}
Expand Down Expand Up @@ -287,7 +287,10 @@ func ImportInfraSourceGroup(c echo.Context) error {
var savedInfraInfoList []model.SavedInfraInfo

for _, conn := range *list {
savedInfraInfo, _ := doImportInfra(conn.ID)
savedInfraInfo, err := doImportInfra(conn.ID)
if err != nil {
return common.ReturnErrorMsg(c, err.Error())
}
savedInfraInfoList = append(savedInfraInfoList, *savedInfraInfo)
}

Expand Down

0 comments on commit 89ec840

Please sign in to comment.