From 4f9e8f0a39663d198c042ddfb1354a22a9881883 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 5 Nov 2018 20:53:07 +0300 Subject: [PATCH] Inherit all errors from ASN1Error class --- VERSION | 2 +- doc/news.rst | 6 ++++++ pyderasn.py | 13 ++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 69df05f..515be8f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.3 +4.4 diff --git a/doc/news.rst b/doc/news.rst index cc3e6a8..f5e8150 100644 --- a/doc/news.rst +++ b/doc/news.rst @@ -1,6 +1,12 @@ News ==== +.. _release4.4: + +4.4 +--- +* All errors are inherited from ASN1Error class + .. _release4.3: 4.3 diff --git a/pyderasn.py b/pyderasn.py index 9c4da4e..2e74bda 100755 --- a/pyderasn.py +++ b/pyderasn.py @@ -642,7 +642,10 @@ LENINDEF_PP_CHAR = "I" if PY2 else "∞" # Errors ######################################################################## -class DecodeError(Exception): +class ASN1Error(ValueError): + pass + +class DecodeError(ASN1Error): def __init__(self, msg="", klass=None, decode_path=(), offset=0): """ :param str msg: reason of decode failing @@ -697,7 +700,7 @@ class InvalidOID(DecodeError): pass -class ObjUnknown(ValueError): +class ObjUnknown(ASN1Error): def __init__(self, name): super(ObjUnknown, self).__init__() self.name = name @@ -709,7 +712,7 @@ class ObjUnknown(ValueError): return "%s(%s)" % (self.__class__.__name__, self) -class ObjNotReady(ValueError): +class ObjNotReady(ASN1Error): def __init__(self, name): super(ObjNotReady, self).__init__() self.name = name @@ -721,7 +724,7 @@ class ObjNotReady(ValueError): return "%s(%s)" % (self.__class__.__name__, self) -class InvalidValueType(ValueError): +class InvalidValueType(ASN1Error): def __init__(self, expected_types): super(InvalidValueType, self).__init__() self.expected_types = expected_types @@ -735,7 +738,7 @@ class InvalidValueType(ValueError): return "%s(%s)" % (self.__class__.__name__, self) -class BoundsError(ValueError): +class BoundsError(ASN1Error): def __init__(self, bound_min, value, bound_max): super(BoundsError, self).__init__() self.bound_min = bound_min -- 2.44.0