mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Revise err handling for CSV storage constructor
NewFileCSVStorage() now returns an error besides the storage struct itself, which is logged and returned instead of calling log.Fatal() which was causing the engine to crash. Fixed compilation errors by creating the CSVStorage separately and passing it as an argument to the TpReader constructor.
This commit is contained in:
@@ -118,8 +118,15 @@ func (apiv2 *APIerSv2) LoadTariffPlanFromFolder(attrs *utils.AttrLoadTpFromFolde
|
||||
} else if !fi.IsDir() {
|
||||
return utils.ErrInvalidPath
|
||||
}
|
||||
|
||||
// initialize CSV storage
|
||||
csvStorage, err := engine.NewFileCSVStorage(utils.CSVSep, attrs.FolderPath)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
|
||||
loader, err := engine.NewTpReader(apiv2.DataManager.DataDB(),
|
||||
engine.NewFileCSVStorage(utils.CSVSep, attrs.FolderPath), "", apiv2.Config.GeneralCfg().DefaultTimezone,
|
||||
csvStorage, "", apiv2.Config.GeneralCfg().DefaultTimezone,
|
||||
apiv2.Config.ApierCfg().CachesConns, apiv2.Config.ApierCfg().SchedulerConns,
|
||||
apiv2.Config.DataDbCfg().Type == utils.MetaInternal)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user