Add timeout errors to json output

This commit is contained in:
Tobie Morgan Hitchcock 2018-05-09 22:51:23 +01:00
parent 220d04b696
commit 0615896c0e
5 changed files with 11 additions and 3 deletions

View file

@ -301,7 +301,7 @@ func TestCreate(t *testing.T) {
So(res, ShouldHaveLength, 3)
So(res[1].Result, ShouldHaveLength, 0)
So(res[2].Result, ShouldHaveLength, 0)
So(res[1].Status, ShouldEqual, "ERR")
So(res[1].Status, ShouldEqual, "ERR_TO")
So(res[1].Detail, ShouldEqual, "Query timeout of 1ms exceeded")
})

View file

@ -149,7 +149,7 @@ func TestDelete(t *testing.T) {
So(res, ShouldHaveLength, 3)
So(res[1].Result, ShouldHaveLength, 0)
So(res[2].Result, ShouldHaveLength, 0)
So(res[1].Status, ShouldEqual, "ERR")
So(res[1].Status, ShouldEqual, "ERR_TO")
So(res[1].Detail, ShouldEqual, "Query timeout of 1ns exceeded")
})

View file

@ -542,6 +542,8 @@ func status(e error) (s string) {
return "ERR_FD"
case *IndexError:
return "ERR_IX"
case *TimerError:
return "ERR_TO"
case error:
return "ERR"
}

View file

@ -295,7 +295,7 @@ func TestUpdate(t *testing.T) {
So(res, ShouldHaveLength, 3)
So(res[1].Result, ShouldHaveLength, 0)
So(res[2].Result, ShouldHaveLength, 0)
So(res[1].Status, ShouldEqual, "ERR")
So(res[1].Status, ShouldEqual, "ERR_TO")
So(res[1].Detail, ShouldEqual, "Query timeout of 1ms exceeded")
})

View file

@ -99,6 +99,8 @@ func OutputBase(c *fibre.Context, t string, d Display, m Method, res []*db.Respo
return fibre.NewHTTPError(422, ret.Detail)
case "ERR_IX":
return fibre.NewHTTPError(422, ret.Detail)
case "ERR_TO":
return fibre.NewHTTPError(504, ret.Detail)
default:
return fibre.NewHTTPError(400, ret.Detail)
}
@ -125,6 +127,8 @@ func OutputRest(c *fibre.Context, t string, d Display, m Method, res []*db.Respo
return fibre.NewHTTPError(422, ret.Detail)
case "ERR_IX":
return fibre.NewHTTPError(422, ret.Detail)
case "ERR_TO":
return fibre.NewHTTPError(504, ret.Detail)
default:
return fibre.NewHTTPError(400, ret.Detail)
}
@ -197,6 +201,8 @@ func OutputJson(c *fibre.Context, t string, d Display, m Method, res []*db.Respo
return fibre.NewHTTPError(422, ret.Detail)
case "ERR_IX":
return fibre.NewHTTPError(422, ret.Detail)
case "ERR_TO":
return fibre.NewHTTPError(504, ret.Detail)
default:
return fibre.NewHTTPError(400, ret.Detail)
}