1
0
mirror of https://github.com/beego/bee.git synced 2024-11-25 20:10:55 +00:00

Add types error handler (log)

the usual warning not panic
This commit is contained in:
Konstantin 2016-10-10 17:36:51 +03:00 committed by GitHub
parent 31406ebe5a
commit e8f85a57c2

View File

@ -779,13 +779,22 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
mp.Default = res[1]
switch realType{
case "int","int64", "int32", "int16", "int8":
mp.Default, _ = strconv.Atoi(res[1])
if mp.Default, err = strconv.Atoi(res[1]); err != nil{
ColorLog("[WARN] Invalid default value type(%s): %s\n",realType, res[1])
}
case "bool":
mp.Default, _ = strconv.ParseBool(res[1])
if mp.Default, err = strconv.ParseBool(res[1]); err != nil{
ColorLog("[WARN] Invalid default value type(%s): %s\n",realType, res[1])
}
case "float64":
mp.Default, _ = strconv.ParseFloat(res[1], 64)
if mp.Default, err = strconv.ParseFloat(res[1], 64); err != nil{
ColorLog("[WARN] Invalid default value type(%s): %s\n",realType, res[1])
}
case "float32":
mp.Default, _ = strconv.ParseFloat(res[1], 32)
if mp.Default, err = strconv.ParseFloat(res[1], 32); err != nil{
ColorLog("[WARN] Invalid default value type(%s): %s\n",realType, res[1])
}
default:
mp.Default = res[1]
}