From 1c0f0ba81a7e3fb261c15a7d985d49c55bea874f Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Tue, 7 Apr 2026 16:06:18 +0200 Subject: [PATCH] Bug fix: add exceptions for namespaces --- src/jcloud_docsgen/exceptions.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/jcloud_docsgen/exceptions.py diff --git a/src/jcloud_docsgen/exceptions.py b/src/jcloud_docsgen/exceptions.py new file mode 100644 index 0000000..f6922d4 --- /dev/null +++ b/src/jcloud_docsgen/exceptions.py @@ -0,0 +1,30 @@ +# Copyright 2026 jCloud Services GbR + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +class NamespaceError(ValueError): + ''' + Base class for namespace errors. + ''' + def __init__(self, *args: object, namespace_identifier: str = '') -> None: + super().__init__(*args) + self.namespace_identifier = namespace_identifier + + def __str__(self): + if not self.args: + return '' + else: + return f'{self.args[0]}{": " if self.namespace_identifier and self.args[0] else ""}{self.namespace_identifier if self.args[0] else ""}' + +class InvalidNamespaceError(NamespaceError): ... +class NamespaceNotFoundError(NamespaceError): ... \ No newline at end of file