Use raise from to reserve stacktrace

This commit is contained in:
mhchia 2020-01-26 23:54:29 +08:00
parent b85bab1a09
commit ddfbf9ffc8
No known key found for this signature in database
GPG Key ID: 389EFBEA1362589A

View File

@ -18,7 +18,7 @@ class RawConnection(IRawConnection):
try:
await self.stream.write(data)
except IOException as error:
raise RawConnError(error)
raise RawConnError from error
async def read(self, n: int = None) -> bytes:
"""
@ -30,7 +30,7 @@ class RawConnection(IRawConnection):
try:
return await self.stream.read(n)
except IOException as error:
raise RawConnError(error)
raise RawConnError from error
async def close(self) -> None:
await self.stream.close()