Adjust + Test
This commit is contained in:
@@ -49,10 +49,15 @@ var ModelsCatalog = map[string]func() utils.DBObject{
|
||||
// Model returns the model object based on the model type
|
||||
func Model(model int) utils.DBObject {
|
||||
log := logs.GetLogger()
|
||||
if _, ok := ModelsCatalog[tools.FromInt(model)]; ok {
|
||||
return ModelsCatalog[tools.FromInt(model)]()
|
||||
if model < 0 || model >= len(tools.Str) {
|
||||
log.Error().Msg("Can't find model: index out of range")
|
||||
return nil
|
||||
}
|
||||
log.Error().Msg("Can't find model " + tools.FromInt(model) + ".")
|
||||
key := tools.FromInt(model)
|
||||
if _, ok := ModelsCatalog[key]; ok {
|
||||
return ModelsCatalog[key]()
|
||||
}
|
||||
log.Error().Msg("Can't find model " + key + ".")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user