feat: check user given path
This commit is contained in:
parent
9993eb9b2b
commit
5ff62ebf06
2 changed files with 10 additions and 2 deletions
|
|
@ -38,7 +38,10 @@ constant searchPathRef : IO.Ref SearchPath := arbitrary _
|
|||
def parseSearchPath (path : String) (sp : SearchPath := ∅) : IO SearchPath := do
|
||||
let ps := System.FilePath.splitSearchPath path;
|
||||
sp ← ps.foldlM (fun (sp : SearchPath) s => match s.splitOn "=" with
|
||||
| [pkg, path] => pure $ sp.insert pkg path
|
||||
| [pkg, path] => do
|
||||
condM (IO.isDir path)
|
||||
(pure $ sp.insert pkg path)
|
||||
(throw $ IO.userError $ "invalid search path, '" ++ path ++ "' is not a directory")
|
||||
| _ => throw $ IO.userError $ "ill-formed search path entry '" ++ s ++ "', should be of form 'pkg=path'")
|
||||
sp;
|
||||
pure sp
|
||||
|
|
|
|||
|
|
@ -427,7 +427,12 @@ int main(int argc, char ** argv) {
|
|||
llvm::InitializeNativeTarget();
|
||||
#endif
|
||||
|
||||
init_search_path();
|
||||
try {
|
||||
init_search_path();
|
||||
} catch (lean::throwable & ex) {
|
||||
std::cerr << "error: " << ex.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
options opts;
|
||||
optional<std::string> server_in;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue