From b15f3b9b0e395982870711de8ff0d373259ade1f Mon Sep 17 00:00:00 2001 From: jMyles Date: Thu, 8 Feb 2018 11:30:24 -0800 Subject: [PATCH] Raise class-scoped error instead of RuntimeError. --- umbral/config.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/umbral/config.py b/umbral/config.py index a3cbc91..8c66abb 100644 --- a/umbral/config.py +++ b/umbral/config.py @@ -5,24 +5,27 @@ class _CONFIG: __curve = None __params = None + class UmbralConfigurationError(RuntimeError): + """Raised when somebody does something dumb re: configuration.""" + @classmethod def params(cls): if not cls.__params: - raise RuntimeError("No default curve has been set; you need one for default params.") + raise cls.UmbralConfigurationError("No default curve has been set; you need one for default params.") else: return cls.__params @classmethod def curve(cls): if not cls.__curve: - raise RuntimeError("No default curve has been set.") + raise cls.UmbralConfigurationError("No default curve has been set.") else: return cls.__curve @classmethod def set_curve(cls, curve: ec.EllipticCurve=None): if cls.__curve: - raise RuntimeError("You can only set the default curve once. Do it once and then leave it alone.") + raise cls.UmbralConfigurationError("You can only set the default curve once. Do it once and then leave it alone.") else: from umbral.params import UmbralParameters cls.__curve = curve