Skip to content

Commit

Permalink
fix: change apiError logic & add terminate log else logic
Browse files Browse the repository at this point in the history
  • Loading branch information
a3828162 committed Nov 25, 2024
1 parent 19a9e87 commit 07d6320
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 88 deletions.
28 changes: 14 additions & 14 deletions internal/sbi/processor/generate_auth_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ func (p *Processor) ConfirmAuthDataProcedure(c *gin.Context,
ctx, &createAuthStatusRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
logger.UeauLog.Errorln("ConfirmAuth err:", err.Error())
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -155,18 +155,18 @@ func (p *Processor) GenerateAuthDataProcedure(
if err != nil {
logger.ProcLog.Errorf("Error on QueryAuthSubsData: %+v", err)
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
switch apiError.ErrorStatus {
case http.StatusNotFound:
logger.UeauLog.Warnf("Return from UDR QueryAuthSubsData error")
default:
logger.UeauLog.Errorln("Return from UDR QueryAuthSubsData error")
}
return
}
switch apiError.ErrorStatus {
case http.StatusNotFound:
logger.UeauLog.Warnf("Return from UDR QueryAuthSubsData error")
default:
logger.UeauLog.Errorln("Return from UDR QueryAuthSubsData error")
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down
96 changes: 48 additions & 48 deletions internal/sbi/processor/subscriber_data_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func (p *Processor) GetAmDataProcedure(c *gin.Context, supi string, plmnID strin
QueryAmData(ctx, &queryAmDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -158,12 +158,12 @@ func (p *Processor) GetSupiProcedure(c *gin.Context,
ctx, &queryAmDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand All @@ -183,12 +183,12 @@ func (p *Processor) GetSupiProcedure(c *gin.Context,
&querySmfSelectDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand All @@ -210,12 +210,12 @@ func (p *Processor) GetSupiProcedure(c *gin.Context,
ctx, &querySmfRegListRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -260,12 +260,12 @@ func (p *Processor) GetSupiProcedure(c *gin.Context,
QuerySmData(ctx, &querySmDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand All @@ -289,12 +289,12 @@ func (p *Processor) GetSupiProcedure(c *gin.Context,
ctx, &queryTraceDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -392,12 +392,12 @@ func (p *Processor) GetSmDataProcedure(
if err != nil {
logger.ProcLog.Errorf("QuerySmData Error: %+v", err)
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -458,12 +458,12 @@ func (p *Processor) GetNssaiProcedure(c *gin.Context, supi string, plmnID string
QueryAmData(ctx, &queryAmDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -503,12 +503,12 @@ func (p *Processor) GetSmfSelectDataProcedure(c *gin.Context, supi string, plmnI
QuerySmfSelectData(ctx, &querySmfSelectDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -573,12 +573,12 @@ func (p *Processor) SubscribeProcedure(c *gin.Context, sdmSubscription *models.S
ctx, &createSdmSubscriptionsRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -761,12 +761,12 @@ func (p *Processor) GetTraceDataProcedure(c *gin.Context, supi string, plmnID st
ctx, &queryTraceDataRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -808,12 +808,12 @@ func (p *Processor) GetUeContextInSmfDataProcedure(c *gin.Context, supi string,
ctx, &querySmfRegListRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down
48 changes: 24 additions & 24 deletions internal/sbi/processor/ue_context_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func (p *Processor) GetAmf3gppAccessProcedure(c *gin.Context, ueID string, suppo
QueryAmfContext3gpp(ctx, &queryAmfContext3gppRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand All @@ -64,12 +64,12 @@ func (p *Processor) GetAmfNon3gppAccessProcedure(c *gin.Context, queryAmfContext
QueryAmfContextNon3gpp(ctx, &queryAmfContextNon3gppParamOpts)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -110,12 +110,12 @@ func (p *Processor) RegistrationAmf3gppAccessProcedure(c *gin.Context,
&createAmfContext3gppRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -186,12 +186,12 @@ func (p *Processor) RegisterAmfNon3gppAccessProcedure(c *gin.Context,
ctx, &createAmfContextNon3gppRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -455,12 +455,12 @@ func (p *Processor) DeregistrationSmfRegistrationsProcedure(c *gin.Context,
_, err = clientAPI.SMFRegistrationDocumentApi.DeleteSmfRegistration(ctx, &deleteSmfRegistrationRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down Expand Up @@ -504,12 +504,12 @@ func (p *Processor) RegistrationSmfRegistrationsProcedure(
_, err = clientAPI.SMFRegistrationDocumentApi.CreateOrUpdateSmfRegistration(ctx, &createSmfContext3gppRequest)
if err != nil {
apiError, ok := err.(openapi.GenericOpenAPIError)
if !ok {
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
if ok {
c.JSON(apiError.ErrorStatus, apiError.RawBody)
return
}
c.JSON(apiError.ErrorStatus, apiError.RawBody)
problemDetails := openapi.ProblemDetailsSystemFailure(err.Error())
c.JSON(int(problemDetails.Status), problemDetails)
return
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func (a *UdmApp) terminateProcedure() {
case error:
logger.InitLog.Errorf("Deregister NF instance Error[%+v]", err)
}
} else {
logger.InitLog.Infof("Deregister from NRF successfully")
}

logger.InitLog.Infof("Deregister from NRF successfully")

logger.MainLog.Infof("UDM SBI Server terminated")
}

Expand Down

0 comments on commit 07d6320

Please sign in to comment.