Raise read_delim
exception with different msgs
Separate `len(msg_bytes) == 0` and `msg_bytes[-1:] != b"\n"`, to raise `ParseError` with different messages.
This commit is contained in:
parent
37bee9fb16
commit
7405f078e6
|
@ -73,8 +73,12 @@ def encode_delim(msg: bytes) -> bytes:
|
||||||
|
|
||||||
async def read_delim(reader: Reader) -> bytes:
|
async def read_delim(reader: Reader) -> bytes:
|
||||||
msg_bytes = await read_varint_prefixed_bytes(reader)
|
msg_bytes = await read_varint_prefixed_bytes(reader)
|
||||||
if len(msg_bytes) == 0 or msg_bytes[-1:] != b"\n":
|
if len(msg_bytes) == 0:
|
||||||
raise ParseError(f'msg_bytes is not delimited by b"\\n": msg_bytes={msg_bytes}')
|
raise ParseError(f"`len(msg_bytes)` should not be 0")
|
||||||
|
if msg_bytes[-1:] != b"\n":
|
||||||
|
raise ParseError(
|
||||||
|
f'`msg_bytes` is not delimited by b"\\n": `msg_bytes`={msg_bytes}'
|
||||||
|
)
|
||||||
return msg_bytes[:-1]
|
return msg_bytes[:-1]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user