File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 4545 unlazyload_modules ,
4646)
4747from wdoc .utils .typechecker import optional_typecheck
48+ from wdoc .utils .errors import NoInferrableFiletype
4849
4950assert env .WDOC_BEHAVIOR_EXCL_INCL_USELESS in [
5051 "warn" ,
@@ -102,7 +103,7 @@ def infer_filetype(path: str) -> str:
102103 return k
103104 fp = Path (path )
104105 if not fp .exists ():
105- raise Exception (
106+ raise NoInferrableFiletype (
106107 f"Failed to detect 'auto' filetype for '{ fp } ' with regex, and it's not a file (does not exist)"
107108 )
108109 try :
@@ -116,7 +117,7 @@ def infer_filetype(path: str) -> str:
116117 # start = temp.read(1024)
117118 # info = magic.from_buffer(start).lower()
118119 except Exception as err :
119- raise Exception (
120+ raise NoInferrableFiletype (
120121 f"Failed to detect 'auto' filetype for '{ fp } ' with regex and even python-magic. Error: '{ err } '"
121122 ) from err
122123 if "pdf" in info :
@@ -126,7 +127,9 @@ def infer_filetype(path: str) -> str:
126127 elif "epub" in info :
127128 return "epub"
128129 else :
129- raise Exception (f"No more python magic heuristics to try for path '{ path } '" )
130+ raise NoInferrableFiletype (
131+ f"No more python magic heuristics to try for path '{ path } '"
132+ )
130133
131134
132135@optional_typecheck
You can’t perform that action at this time.
0 commit comments