]> Savannah Git Hosting - gnulib.git/commitdiff
special "module not found" error
authorDmitry Selyutin <ghostmansd@gmail.com>
Thu, 14 Sep 2017 16:37:26 +0000 (19:37 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Thu, 14 Sep 2017 19:46:59 +0000 (22:46 +0300)
pygnulib/error.py
pygnulib/filesystem.py

index 4504c0fbbb17c9adcf1672dcacfad5c374932635..a09a0959265da3f9ddf7cfa11d6ee78b8b594200 100644 (file)
@@ -65,6 +65,14 @@ class M4BaseMismatchError(Exception):
 
 
 
+class GnulibModuleNotFoundError(Exception):
+    """module not found"""
+    def __init__(self, name):
+        fmt = "module not found: {0}"
+        super().__init__(fmt.format(name))
+
+
+
 class UnknownLicenseError(Exception):
     """module lacks a license"""
     def __init__(self, module):
index 81f17b038129cff253f36c37cfd15b4117ba271b..21a4c7791e23a996312c6dad8be7be3f77415657 100644 (file)
@@ -7,6 +7,7 @@ import os as _os_
 
 
 from .error import type_assert as _type_assert_
+from .error import GnulibModuleNotFoundError as _GnulibModuleNotFoundError_
 from .config import Base as _BaseConfig_
 from .module import Base as _BaseModule_
 from .module import File as _FileModule_
@@ -123,7 +124,10 @@ class GnulibGit(Directory):
         if name in GnulibGit._EXCLUDE_:
             raise ValueError("illegal module name")
         path = _os_.path.join(self["modules"], name)
-        return _FileModule_(path, name=name) if full else _BaseModule_(name)
+        try:
+            return _FileModule_(path, name=name) if full else _BaseModule_(name)
+        except FileNotFoundError:
+            raise _GnulibModuleNotFoundError_(name)
 
 
     def modules(self, full=True):