projects
/
arvados.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d3512ad
)
10467: Use ErrClientDisconnect. Convert type assertion panic to 500 error.
author
Tom Clegg <tom@curoverse.com>
Mon, 7 Nov 2016 03:11:52 +0000
(22:11 -0500)
committer
Tom Clegg <tom@curoverse.com>
Mon, 7 Nov 2016 15:43:02 +0000
(10:43 -0500)
services/keepstore/handlers.go
patch
|
blob
|
history
diff --git
a/services/keepstore/handlers.go
b/services/keepstore/handlers.go
index 588ee048f021da8188babdd81fd75b7049351893..2c680d355e1268caa1d953dbb5353e3e68715f83 100644
(file)
--- a/
services/keepstore/handlers.go
+++ b/
services/keepstore/handlers.go
@@
-192,8
+192,11
@@
func PutBlockHandler(resp http.ResponseWriter, req *http.Request) {
bufs.Put(buf)
if err != nil {
bufs.Put(buf)
if err != nil {
- ke := err.(*KeepError)
- http.Error(resp, ke.Error(), ke.HTTPCode)
+ code := http.StatusInternalServerError
+ if err, ok := err.(*KeepError); ok {
+ code = err.HTTPCode
+ }
+ http.Error(resp, err.Error(), code)
return
}
return
}
@@
-572,7
+575,7
@@
func GetBlock(ctx context.Context, hash string, buf []byte, resp http.ResponseWr
size, err := vol.Get(ctx, hash, buf)
select {
case <-ctx.Done():
size, err := vol.Get(ctx, hash, buf)
select {
case <-ctx.Done():
- return 0,
ctx.Err()
+ return 0,
ErrClientDisconnect
default:
}
if err != nil {
default:
}
if err != nil {
@@
-655,7
+658,7
@@
func PutBlock(ctx context.Context, block []byte, hash string) (int, error) {
return vol.Replication(), nil // success!
}
if ctx.Err() != nil {
return vol.Replication(), nil // success!
}
if ctx.Err() != nil {
- return 0,
ctx.Err()
+ return 0,
ErrClientDisconnect
}
}
}
}
@@
-669,7
+672,7
@@
func PutBlock(ctx context.Context, block []byte, hash string) (int, error) {
for _, vol := range writables {
err := vol.Put(ctx, hash, block)
if ctx.Err() != nil {
for _, vol := range writables {
err := vol.Put(ctx, hash, block)
if ctx.Err() != nil {
- return 0,
ctx.Err()
+ return 0,
ErrClientDisconnect
}
if err == nil {
return vol.Replication(), nil // success!
}
if err == nil {
return vol.Replication(), nil // success!