mirror of
https://github.com/beego/bee.git
synced 2024-11-22 10:10:53 +00:00
Add types error handler (log)
the usual warning not panic
This commit is contained in:
parent
31406ebe5a
commit
e8f85a57c2
21
g_docs.go
21
g_docs.go
@ -779,15 +779,24 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
|
|||||||
mp.Default = res[1]
|
mp.Default = res[1]
|
||||||
switch realType{
|
switch realType{
|
||||||
case "int","int64", "int32", "int16", "int8":
|
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":
|
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":
|
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":
|
case "float32":
|
||||||
mp.Default, _ = strconv.ParseFloat(res[1], 32)
|
if mp.Default, err = strconv.ParseFloat(res[1], 32); err != nil{
|
||||||
default:
|
ColorLog("[WARN] Invalid default value type(%s): %s\n",realType, res[1])
|
||||||
mp.Default = res[1]
|
}
|
||||||
|
default:
|
||||||
|
mp.Default = res[1]
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ColorLog("[WARN] Invalid default value: %s\n", defaultValue)
|
ColorLog("[WARN] Invalid default value: %s\n", defaultValue)
|
||||||
|
Loading…
Reference in New Issue
Block a user