-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
improve error types and messages #4744
Comments
+10^6 |
After writing #4745, I have come to see This seems like a good project for someone looking for an excuse to get some exposure to |
I think this issue is to wide, so we need to narrow it down.
@JeffBezanson said something about the efficiency of adding messages to exceptions in #2144 (comment), but somehow the string allocation and processing should be possible to defer to after we know there is an error. Another approach is to specialize the |
We should
|
We also have to decide what to do with |
A relatively small task that would be helpful in this regard:
|
There were several points made in https://groups.google.com/d/msg/julia-dev/NDtV8aa8XLk/ZSysXqOvun0J that may be worth considering. |
Another major improvement would be to fully qualify names. I just encountered ("in the wild") a case where there was a module defining a |
Should we have every Base error have a msg attribute (not sure if it's possible to "enforce" this - sounds like a trait!) to have a default for each error, or (in some cases maybe :s ) make a message required ? Happy to put something together here, if this is desired, I have the first part already (print DomainError rather than ERROR):
IMO this is better/more flexible than:
|
While it sounds good in principle, depending on implementation there might be some unintended side effects. See #6698 (comment). See also #8784 |
As we have a specific method to print The question is whether we want to print a short doc, or refer to something like |
By default (in python) if you do ValueError() is equivalent to ValueError(""), i.e. it prints:
We could do the same (so as to cause less clutter). |
Ah I hadn't seen the performance issue (thanks for linking to that). I still think that:
would be a better exception (even with an empty message, which is currently added on a per-exception basis with
|
The exception types thrown in Base has been improved for many methods. It would be more helpful to open issues on individual errors that need improvement so I'm closing this. |
I think it would really be to our benefit to clean up how errors are printed in Julia. Examples:
This doesn't tell me anything about the type of the error (in case I wanted to
catch
it, for instance), but does tell me something mildly helpful; namely that I attempted to call a function that doesn't exist.On the other hand, these tell me the type of the error but don't tell me much beyond that. It'd be nice to have some kind of human-readable string to make this a little friendlier.
This is the nicest so far because everything I'm looking for is there (type for catching, description, etc....), however it's not exactly printed in the nicest way; it's printed out in faux-"AST literal" fashion. I don't know if there's a much better way to print exceptions out, but I'm willing to think about it if others agree.
I'd like to propose that when exceptions in
Base
throw and are printed to the console, that they are represented with their type, a human-readable description of the error (simple exceptions such asBoundsError()
could have a default boilerplate so as to not have developers copy-pasting the same string everywhere)The text was updated successfully, but these errors were encountered: