]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
datamodel: types: verbose errors for paths
authorAleš Mrázek <ales.mrazek@nic.cz>
Mon, 24 Jul 2023 21:36:19 +0000 (23:36 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Thu, 27 Jul 2023 12:39:37 +0000 (12:39 +0000)
manager/knot_resolver_manager/datamodel/types/files.py

index 99fd8c21f5480eb5917a378423d09fd75c7c4ff2..6244a6d37dd798914e9b6161604128ed33e46f21 100644 (file)
@@ -101,7 +101,7 @@ class AbsoluteDir(Dir):
     ) -> None:
         super().__init__(source_value, parents=parents, object_path=object_path)
         if self.strict_validation and not self._value.is_absolute():
-            raise ValueError("path not absolute")
+            raise ValueError(f"path '{self._value}' is not absolute")
 
 
 class File(UncheckedPath):
@@ -115,9 +115,9 @@ class File(UncheckedPath):
     ) -> None:
         super().__init__(source_value, parents=parents, object_path=object_path)
         if self.strict_validation and not self._value.exists():
-            raise ValueError("file does not exist")
+            raise ValueError(f"file '{self._value}' does not exist")
         if self.strict_validation and not self._value.is_file():
-            raise ValueError("path is not a file")
+            raise ValueError(f"path '{self._value}' is not a file")
 
 
 class FilePath(UncheckedPath):
@@ -135,4 +135,4 @@ class FilePath(UncheckedPath):
         if self.strict_validation and not p.exists() or not p.is_dir():
             raise ValueError(f"path '{self._value}' does not point inside an existing directory")
         if self.strict_validation and self._value.is_dir():
-            raise ValueError("path points to a directory when we expected a file")
+            raise ValueError(f"path '{self._value}' points to a directory when we expected a file")