From 6a7c5fd265d6fc4bc529e1aa6b44f1db3387c9d0 Mon Sep 17 00:00:00 2001 From: Sebastian Pfitzner Date: Mon, 25 Sep 2023 10:57:26 +0200 Subject: [PATCH] feat: print file path on failure in loadfile --- src/server.jl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/server.jl b/src/server.jl index 80c7d29d..2293aa82 100644 --- a/src/server.jl +++ b/src/server.jl @@ -32,12 +32,17 @@ function setfile(server::FileServer, path::String, file::File) end getfile(server::FileServer, path::String) = server.files[path] function loadfile(server::FileServer, path::String) - source = read(path, String) - cst = CSTParser.parse(source, true) - f = File(path, source, cst, nothing, server) - setroot(f, f) - setfile(server, path, f) - return getfile(server, path) + try + source = read(path, String) + cst = CSTParser.parse(source, true) + f = File(path, source, cst, nothing, server) + setroot(f, f) + setfile(server, path, f) + return getfile(server, path) + catch + @info "Could not load $(path) from disk." + rethrow() + end end getsymbols(env::ExternalEnv) = env.symbols