From 84861ad768f1cb3c34784bbfeb536119732f1ee0 Mon Sep 17 00:00:00 2001 From: David Garcia Date: Wed, 8 Apr 2020 09:48:21 +0200 Subject: [PATCH] Add N2VCNotFound exception Change-Id: I83702862086996adaefbfb9721f08f40bc943a44 Signed-off-by: David Garcia --- n2vc/exceptions.py | 12 ++++++++++++ n2vc/n2vc_juju_conn.py | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/n2vc/exceptions.py b/n2vc/exceptions.py index a663c62..815d4ea 100644 --- a/n2vc/exceptions.py +++ b/n2vc/exceptions.py @@ -125,6 +125,18 @@ class N2VCInvalidCertificate(N2VCException): return '<{}> Invalid certificate: {}'.format(type(self), super().__str__()) +class N2VCNotFound(N2VCException): + """ + Not found + """ + + def __init__(self, message: str = ''): + N2VCException.__init__(self, message=message) + + def __str__(self): + return '<{}> Not found: {}'.format(type(self), super().__str__()) + + class K8sException(Exception): """ K8s exception diff --git a/n2vc/n2vc_juju_conn.py b/n2vc/n2vc_juju_conn.py index 4456dd9..6b8ac09 100644 --- a/n2vc/n2vc_juju_conn.py +++ b/n2vc/n2vc_juju_conn.py @@ -32,7 +32,7 @@ from n2vc.n2vc_conn import N2VCConnector from n2vc.n2vc_conn import obj_to_dict, obj_to_yaml from n2vc.exceptions \ import N2VCBadArgumentsException, N2VCException, N2VCConnectionException, \ - N2VCExecutionException, N2VCInvalidCertificate + N2VCExecutionException, N2VCInvalidCertificate, N2VCNotFound from n2vc.juju_observer import JujuModelObserver from juju.controller import Controller @@ -1294,7 +1294,7 @@ class N2VCJujuConnector(N2VCConnector): model = await self._juju_get_model(model_name=model_name) if not model: - raise N2VCException( + raise N2VCNotFound( message="Model {} does not exist".format(model_name) ) -- 2.25.1