Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw correct LoadError from compilecache #12724

Closed
stevengj opened this issue Aug 21, 2015 · 2 comments
Closed

throw correct LoadError from compilecache #12724

stevengj opened this issue Aug 21, 2015 · 2 comments
Labels
compiler:precompilation Precompilation of modules error handling Handling of exceptions by Julia or the user

Comments

@stevengj
Copy link
Member

Since Base.compilecache runs in a subprocess, any exception that is thrown is printed to stderr but is not rethrown in the parent process, which just throws an ErrorException.

This is annoying in the case of a module Foo that has a syntax error or something else that would ordinarily throw a LoadError on import. All of the nice formatting etcetera (e.g. coloring in the terminal, or special handling in IJulia/Jupyter) is lost and the LoadError gets printed as plain text, and then an ErrorException is thrown in addition.

Is there some way to serialize the LoadError and backtrace from the child process so that they get rethrown in the parent process?

@stevengj stevengj added error handling Handling of exceptions by Julia or the user compiler:precompilation Precompilation of modules labels Aug 21, 2015
@bermanmaxim
Copy link

I hit this same issue today, by trying to catch the absence of a file loaded using JLD:

using JLD
try
    a = load("test.jld", "w0")
catch y
    if isa(y, LoadError)
        a = rand(1000);
        save("test.jls", "a", a);
    else
        rethrow()
    end
end

LoadError: File test.jld cannot be found
while loading In[45], in expression starting on line 9

 in jldopen at /home/.julia/v0.4/JLD/src/JLD.jl:142
 in jldopen at /home/.julia/v0.4/JLD/src/JLD.jl:209
 in jldopen at /home/.julia/v0.4/JLD/src/JLD.jl:219
 in load at /home/.julia/v0.4/JLD/src/JLD.jl:1111

the catch sees y as a general ErrorException instead of a LoadError, despite this name being printed on screen.

@timholy
Copy link
Member

timholy commented Aug 22, 2021

LoadError changed quite drastically in #29901, #30900, and perhaps others. I suggest we close this as the test case is no longer reproducible and the OP doesn't contain a test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

No branches or pull requests

4 participants