From 540875b2be8ba3a7b9b6d593938e05b95a5e80f6 Mon Sep 17 00:00:00 2001 From: Jocelyn Kevorkian Date: Tue, 24 Mar 2020 12:58:20 +0100 Subject: [PATCH] Add support for RegexError --- kaitaistruct.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kaitaistruct.py b/kaitaistruct.py index d135c7a..a0217f1 100644 --- a/kaitaistruct.py +++ b/kaitaistruct.py @@ -464,3 +464,12 @@ class ValidationNotAnyOfError(ValidationFailedError): def __init__(self, actual, io, src_path): super(ValidationNotAnyOfError, self).__init__("not any of the list, got %s" % (repr(actual)), io, src_path) self.actual = actual + +class ValidationRegexMatchError(ValidationFailedError): + """Signals validation failure: we required "actual" value to match + the regex, but it turned out that it's not. + """ + def __init__(self, regex, actual, io, src_path): + super(ValidationRegexMatchError, self).__init__("no match with regex %s, got %s" % (repr(regex), repr(actual)), io, src_path) + self.actual = actual + self.regex = regex \ No newline at end of file