JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.63k stars 5.48k forks source link

error code #'s #6386

Closed vtjnash closed 10 years ago

vtjnash commented 10 years ago

Proposal: add error codes to all julia internal error messages which can be cross-referenced against an extended documentation page that describes each error, giving more verbose descriptions, examples, gotchas, and solutions

JeffBezanson commented 10 years ago

Improving error messages and even adding doc links is great, but assigning unique codes to each just strikes me as a tedious and unnecessary burden. Error messages that are very tricky should just be longer and more descriptive.

vtjnash commented 10 years ago

i wanted to use the codes as a way of reducing the tedium of making doc links. perhaps the text itself is enough to cross-reference to the docs, but what if you wanted to update the text?

while writing twitter-worthy error messages sounds like a great goal, i'm pretty bad at it. writing a paragraph (with the added benefit of having room for examples) seemed like a worthwhile tradeoff.

how would we go about this? lookup table in showerror that adds a hyperlink? hyperlink to where, RTD?

jiahao commented 10 years ago

Not orthogonal to #5694 and related error reporting issues like #4744, #4836, etc.

It will be particularly challenging to implement this proposal for a centralized table of error codes when the errors are thrown by underlying libraries like LAPACKException and ARPACKException, since the error codes encapsulated are context-sensitive and mean different things depending on the specific external procedure that threw the error to begin with. Not to mention that ARPACK's documentation is not exactly a paragon of clarity about its own error codes...

vtjnash commented 10 years ago

Ultimately I agree we will have to bite the bullet and remove error in favor of throwing specific exception types. -- Jeff, in #5694

I guess this would effectively assign unique codes to each error type

JeffBezanson commented 10 years ago

Uh, that's not the same as assigning a numeric code to every error.

vtjnash commented 10 years ago

a type pointer is sort of like a unique numeric code, no?

JeffBezanson commented 10 years ago

But there isn't a different type for every error message; you group the errors into a reasonable number of exception types. See for example python's exception hierarchy.

Further distinguishing errors is not what I'm against; here I'm really just against the idea of numeric codes specifically. Everything in a computer is numbers underneath, so that's clearly not what I'm talking about.

tknopp commented 10 years ago

I am also for a better exception hierarchy instead of error codes. This is how it works in Java and C# and it actually works quite well to localize bugs. I have seen C code that did arithmetics on error codes (to look if the error is in a certain range) and this was just scary...

ScottPJones commented 9 years ago

Hmm... I know this was closed a year ago, but there is an argument for using error codes (not necessarily centralized error codes) that was not raised... the ability to have locale specific messages. I am all for a better exception hierarchy, but using sets of error codes (best set up with Enums, not integers), possibly one set for each exception type, can work very well, and avoids the idea that everything has to be English...