Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis 2015-06-03 06:52:39 -07:00
parent b8b16b78f4
commit 56349665b7
13 changed files with 334 additions and 197 deletions

View file

@ -16,9 +16,14 @@ func serveJSON(w http.ResponseWriter, v interface{}) error {
sc := http.StatusInternalServerError
if errs, ok := v.(errcode.Errors); ok && len(errs) > 0 {
sc = errs[0].Code.Descriptor().HTTPStatusCode
if sc == 0 {
sc = http.StatusInternalServerError
if err, ok := errs[0].(errcode.ErrorCoder); ok {
if sc2 := err.ErrorCode().Descriptor().HTTPStatusCode; sc2 != 0 {
sc = sc2
}
}
} else if err, ok := v.(errcode.ErrorCoder); ok {
if sc2 := err.ErrorCode().Descriptor().HTTPStatusCode; sc2 != 0 {
sc = sc2
}
}