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 45
45
unlazyload_modules ,
46
46
)
47
47
from wdoc .utils .typechecker import optional_typecheck
48
+ from wdoc .utils .errors import NoInferrableFiletype
48
49
49
50
assert env .WDOC_BEHAVIOR_EXCL_INCL_USELESS in [
50
51
"warn" ,
@@ -102,7 +103,7 @@ def infer_filetype(path: str) -> str:
102
103
return k
103
104
fp = Path (path )
104
105
if not fp .exists ():
105
- raise Exception (
106
+ raise NoInferrableFiletype (
106
107
f"Failed to detect 'auto' filetype for '{ fp } ' with regex, and it's not a file (does not exist)"
107
108
)
108
109
try :
@@ -116,7 +117,7 @@ def infer_filetype(path: str) -> str:
116
117
# start = temp.read(1024)
117
118
# info = magic.from_buffer(start).lower()
118
119
except Exception as err :
119
- raise Exception (
120
+ raise NoInferrableFiletype (
120
121
f"Failed to detect 'auto' filetype for '{ fp } ' with regex and even python-magic. Error: '{ err } '"
121
122
) from err
122
123
if "pdf" in info :
@@ -126,7 +127,9 @@ def infer_filetype(path: str) -> str:
126
127
elif "epub" in info :
127
128
return "epub"
128
129
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
+ )
130
133
131
134
132
135
@optional_typecheck
You can’t perform that action at this time.
0 commit comments