fix: reraise exception in readLp

This commit is contained in:
Dmitriy Ryajov 2020-01-29 12:05:05 -06:00
parent e157d71a46
commit 171d60fb52
1 changed files with 4 additions and 0 deletions

View File

@ -130,8 +130,12 @@ proc readLp*(s: Connection): Future[seq[byte]] {.async, gcsafe.} =
await s.readExactly(addr result[0], int(size)) await s.readExactly(addr result[0], int(size))
except LPStreamIncompleteError as exc: except LPStreamIncompleteError as exc:
trace "remote connection ended unexpectedly", exc = exc.msg trace "remote connection ended unexpectedly", exc = exc.msg
result.setLen(0)
raise exc
except LPStreamReadError as exc: except LPStreamReadError as exc:
trace "couldn't read from stream", exc = exc.msg trace "couldn't read from stream", exc = exc.msg
result.setLen(0)
raise exc
proc writeLp*(s: Connection, msg: string | seq[byte]): Future[void] {.gcsafe.} = proc writeLp*(s: Connection, msg: string | seq[byte]): Future[void] {.gcsafe.} =
## write lenght prefixed ## write lenght prefixed