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
IndexOutOfBoundsException detail message #9797
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9797?orig=1 |
@SethTisue said: |
@ruippeixotog said:
I'm willing to take on this, if you think it's a good idea. @Ichoran, what do you think? Is it worth it performance-wise? |
@Ichoran said (edited on Nov 13, 2016 12:51:02 AM UTC): For example, in class TinyException {
var n,m = 0;
def foo() { println("The real work is here.") }
def bar(b: Boolean) {
if (b) foo else throw new Exception("Argh.")
}
def baz(b: Boolean) {
if (b) foo else throw new Exception("n is " + n + " and m is " + m)
}
} bar is under the automatic inlining limit but baz is not. |
Ben said (edited on Nov 15, 2016 9:13:17 AM UTC): I think it costs nothing if you just add some text like "Can't access " + n + "th element in List". Just throw n is so ambiguous that somebody is totally confused if he uses for example only exception.getMessage(). |
@ruippeixotog said: @Ichoran, is there an easy way I can check if methods are able of being JIT-inlined? If not, is there some golden rule to that? |
@Ichoran said: So if a method looks like a forwarder to another method, I'd try to keep it as such. @ben - People sometimes catch exceptions, at which point they do become part of the normal runtime in unusual cases. Changing the execution time by several orders of magnitude is, therefore, not something to do lightly. Creating an exception is O(n) in the depth of the stack, and has a pretty high constant factor also. Adding some constant or log term is fine. Adding O(m) with m >>> n is probably not, because it could make someone's normal error-handling code a performance bottleneck. |
Ben said: |
Fixed in scala/scala#7210. |
Hi,
I've noticed that the IndexOutOfBoundsException only returns the size of the collection as detail message. I think it should be a more detailed message like "size is n, but m is expected".
The class where I found the unfavorable message was scala.collection.LinearSeqOptimized$class.apply
what do you mean, would it be a good idea to change the message?
The text was updated successfully, but these errors were encountered: