golang beego错误消息

时间:2019-03-27 04:10:56

标签: json api go beego

问题是如何以字符串形式读取Error的主体数据?这样定义错误是否正确?

控制器代码

createKeyPair, err := compute.CreateKeypair(raw["keyPairName"].(string))

if err != nil {
    i.Data["json"] = err                    <------------ here it is
} else {
    i.Data["json"] = createKeyPair
}

i.ServeJSON()

我得到错误

{
"DefaultErrString": "",
"Info": "",
"URL": "http://controller:8774/v2.1/os-keypairs",
"Method": "POST",
"Expected": [
    200
],
"Actual": 409,
"Body": "eyJjb25mbGljdGluZ1JlcXVlc3QiOiB7Im1lc3NhZ2UiOiAiS2V5IHBhaXIgJ2JhYmFiYWJhJyBhbHJlYWR5IGV4aXN0cy4iLCAiY29kZSI6IDQwOX19"

}

0 个答案:

没有答案