]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Use new error handling philosophy
authorMatt Joiner <anacrolix@gmail.com>
Sat, 20 Feb 2016 03:40:28 +0000 (14:40 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 20 Feb 2016 03:40:28 +0000 (14:40 +1100)
client.go

index 0dc753abc998aea0e8e2eeac6299c85bea3654be..b96cbd5f9b0ec04ec8d4cb11dcd22ed3a34ea559 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1361,11 +1361,11 @@ func (me *Client) sendChunk(t *torrent, c *connection, r request) error {
        tp.waitNoPendingWrites()
        p := t.Info.Piece(int(r.Index))
        n, err := dataReadAt(t.data, b, p.Offset()+int64(r.Begin))
-       if err != nil {
-               return err
-       }
        if n != len(b) {
-               log.Fatal(b)
+               if err == nil {
+                       panic("expected error")
+               }
+               return err
        }
        c.Post(pp.Message{
                Type:  pp.Piece,