Skip to content

Commit 7ac64c7

Browse files
authored
Merge pull request #377 from julia-vscode/sp/catch-loadfile
feat: print file path on failure in loadfile
2 parents 74ec406 + 6a7c5fd commit 7ac64c7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/server.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ function setfile(server::FileServer, path::String, file::File)
3232
end
3333
getfile(server::FileServer, path::String) = server.files[path]
3434
function loadfile(server::FileServer, path::String)
35-
source = read(path, String)
36-
cst = CSTParser.parse(source, true)
37-
f = File(path, source, cst, nothing, server)
38-
setroot(f, f)
39-
setfile(server, path, f)
40-
return getfile(server, path)
35+
try
36+
source = read(path, String)
37+
cst = CSTParser.parse(source, true)
38+
f = File(path, source, cst, nothing, server)
39+
setroot(f, f)
40+
setfile(server, path, f)
41+
return getfile(server, path)
42+
catch
43+
@info "Could not load $(path) from disk."
44+
rethrow()
45+
end
4146
end
4247

4348
getsymbols(env::ExternalEnv) = env.symbols

0 commit comments

Comments
 (0)