From 4c625553bf34de970662ade6772a7d011cb76009 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 27 Mar 2024 11:56:25 +0100 Subject: [PATCH] Adding exception classes DateFormatError and WrongDateIsoformatError --- lib/pp_admintools/errors.py | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/pp_admintools/errors.py b/lib/pp_admintools/errors.py index d345e2f..f6f8c52 100644 --- a/lib/pp_admintools/errors.py +++ b/lib/pp_admintools/errors.py @@ -6,11 +6,16 @@ @author: Frank Brehm """ -# own modules +# Third party modules from fb_tools.errors import FbAppError, FbError +# own modules +from .xlate import XLATOR + +_ = XLATOR.gettext + +__version__ = '0.9.0' -__version__ = '0.8.2' # ============================================================================= class DpxError(FbError): @@ -122,6 +127,7 @@ class DpxDeployZonesError(DpxPDNSAppError): pass + # ============================================================================= class CheckLdapDnAttributesError(DpxLdapError): """Special exception class for exceptions in module app.check_ldap_dn_attributes.""" @@ -129,6 +135,34 @@ class CheckLdapDnAttributesError(DpxLdapError): pass +# ============================================================================= +class DateFormatError(DpxError): + """Special exception class, if a date string could not be interpreted as a date string.""" + + pass + +# ============================================================================= +class WrongDateIsoformatError(DateFormatError): + """Special exception class, if a date string could not be interpreted as an ISO date string.""" + + # ----------------------------------------------------- + def __init__(self, datestr): + """ + Initialise a WrongDateIsoformatError exception. + + @param datestr: The date string, which could not be interpreted. + @type datestr: str + + """ + self.datestr = str(datestr) + + # ----------------------------------------------------- + def __str__(self): + """Typecast into a string for error output.""" + return _('The date string {!r} could not be interpreted as an ISO date.').format( + self.datestr) + + # ============================================================================= if __name__ == '__main__': -- 2.39.5