List of errors and what they mean

Is there somewhere where I can see a list of Julia errors, and what they mean? Some are mostly self-explanatory (although it depends on your experience with this kind of stuff!), and some are not. And some might not be part of base and hence hard to list.

E.g. I got a

ERROR: ArgumentError: Invalid Status

and it would be nice to know exactly what a ArgumentError is when I try to debug it.

An ArgumentError is just a means to communicate that the arguments supplied to a function don’t pass some check that is required for the function to give a correct result. This can have lots of reasons, depending on the function, which is usually communicated with a precise error message.

How did you encounter that error/what’s the stacktrace following it? The error message here seems particularly badly written…

1 Like

It was a long list of stuff when I ran an implicit diffeq solver. Something with KLU factorization. It didn’t actually include some of my code in the stack trace which made it messier as well.

You can get a literal list of “all” possible types of errors as subtypes(Exception). You can then use the help?> prompt (eg, ?ArgumentError) to get whatever docstring has been written for an error type. However I imagine most dosctrings are either missing or not very descriptive.

As for your particular ArgumentError: Invalid Status, I’ll agree that this message is not very helpful. I cannot know anything without the stacktrace, but I’m guessing it’s being thrown from a package (although ArgumentError itself is part of base Julia). I’m guessing there’s an input called status or something similar and it got passed an unrecognized value. This doesn’t sound like something that would be directly your fault, but some upstream mistake might have led to it.

One nifty REPL shortcut is this. When presented with a stacktrace, such as

julia> "abcd"[5]
ERROR: BoundsError: attempt to access 4-codeunit String at index [5]
Stacktrace:
 [1] checkbounds
   @ ./strings/basic.jl:216 [inlined]
 [2] codeunit
   @ ./strings/string.jl:117 [inlined]
 [3] getindex(s::String, i::Int64)
   @ Base ./strings/string.jl:238
 [4] top-level scope
   @ REPL[875]:1

You can then type a stacktrace index into the prompt (eg julia> 2 for codeunit in the above example) and press ctrl-q and it will open your editor (if one is configured) at the corresponding place in the code. This also works for the output of the methods function and perhaps a few others.

This can at least help you quickly get to the relevant spot in the code. If you can manage to see what that code is doing, it may be able help you to understand the error in greater depth.

1 Like

Thanks a lot, that is really useful! :slight_smile: