mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 06:09:53 +05:00
Make error handling consistent across Get*Profiles apis
This commit is contained in:
committed by
Dan Christian Bogos
parent
68abf3e506
commit
3d3827bbee
@@ -89,10 +89,7 @@ func (admS *AdminSv1) GetAccounts(ctx *context.Context, args *utils.ArgsItemIDs,
|
||||
var acc *utils.Account
|
||||
acc, err = admS.dm.GetAccount(ctx, tnt, accID)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*accs = append(*accs, acc)
|
||||
}
|
||||
|
||||
@@ -90,10 +90,7 @@ func (admS *AdminSv1) GetActionProfiles(ctx *context.Context, args *utils.ArgsIt
|
||||
var ap *engine.ActionProfile
|
||||
ap, err = admS.dm.GetActionProfile(ctx, tnt, actPrfID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*actPrfs = append(*actPrfs, ap)
|
||||
}
|
||||
|
||||
@@ -90,10 +90,7 @@ func (admS *AdminSv1) GetAttributeProfiles(ctx *context.Context, args *utils.Arg
|
||||
var ap *engine.AttributeProfile
|
||||
ap, err = admS.dm.GetAttributeProfile(ctx, tnt, attrPrfID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*attrPrfs = append(*attrPrfs, ap)
|
||||
}
|
||||
|
||||
@@ -87,10 +87,7 @@ func (admS *AdminSv1) GetChargerProfiles(ctx *context.Context, args *utils.ArgsI
|
||||
var chgrPrf *engine.ChargerProfile
|
||||
chgrPrf, err = admS.dm.GetChargerProfile(ctx, tnt, chrgPrfID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*chrgPrfs = append(*chrgPrfs, chgrPrf)
|
||||
}
|
||||
|
||||
@@ -88,10 +88,7 @@ func (admS *AdminSv1) GetDispatcherProfiles(ctx *context.Context, args *utils.Ar
|
||||
var dspPrf *engine.DispatcherProfile
|
||||
dspPrf, err = admS.dm.GetDispatcherProfile(ctx, tnt, dspPrfID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*dspPrfs = append(*dspPrfs, dspPrf)
|
||||
}
|
||||
|
||||
@@ -90,10 +90,7 @@ func (admS *AdminSv1) GetRateProfiles(ctx *context.Context, args *utils.ArgsItem
|
||||
var ratePrf *utils.RateProfile
|
||||
ratePrf, err = admS.dm.GetRateProfile(ctx, tnt, ratePrfID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*ratePrfs = append(*ratePrfs, ratePrf)
|
||||
}
|
||||
|
||||
@@ -86,10 +86,7 @@ func (admS *AdminSv1) GetResourceProfiles(ctx *context.Context, args *utils.Args
|
||||
var rsPrf *engine.ResourceProfile
|
||||
rsPrf, err = admS.dm.GetResourceProfile(ctx, tnt, rsPrfID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*rsPrfs = append(*rsPrfs, rsPrf)
|
||||
}
|
||||
|
||||
@@ -86,10 +86,7 @@ func (admS *AdminSv1) GetRouteProfiles(ctx *context.Context, args *utils.ArgsIte
|
||||
var rouPrf *engine.RouteProfile
|
||||
rouPrf, err = admS.dm.GetRouteProfile(ctx, tnt, rouPrfID, true, true, utils.NonTransactional)
|
||||
if err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
return
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*rouPrfs = append(*rouPrfs, rouPrf)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user