Add StackError and FormatError (#331)

This commit is contained in:
INADA Naoki 2018-11-20 13:12:49 +09:00 committed by GitHub
parent 8b6ce53cce
commit 44254dd35e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 120 additions and 48 deletions

View file

@ -6,6 +6,7 @@ class UnpackException(Exception):
Exception instead.
"""
class BufferFull(UnpackException):
pass
@ -14,6 +15,14 @@ class OutOfData(UnpackException):
pass
class FormatError(ValueError, UnpackException):
"""Invalid msgpack format"""
class StackError(ValueError, UnpackException):
"""Too nested"""
# Deprecated. Use ValueError instead
UnpackValueError = ValueError
@ -24,6 +33,7 @@ class ExtraData(UnpackValueError):
This exception is raised while only one-shot (not streaming)
unpack.
"""
def __init__(self, unpacked, extra):
self.unpacked = unpacked
self.extra = extra
@ -32,7 +42,7 @@ class ExtraData(UnpackValueError):
return "unpack(b) received extra data."
#Deprecated. Use Exception instead to catch all exception during packing.
# Deprecated. Use Exception instead to catch all exception during packing.
PackException = Exception
PackValueError = ValueError
PackOverflowError = OverflowError