Adjust + Test

This commit is contained in:
mr
2026-02-18 12:24:19 +01:00
parent 842e09f22f
commit fa5c3a3c60
45 changed files with 1166 additions and 1192 deletions

View File

@@ -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
}