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

Enumeration withName should tell what name is missing in case of an exception #9067

Closed
scabug opened this issue Jan 2, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jan 2, 2015

it's a small detail yet might be useful. I find it annoying that a failed Enumeration#withName call tells me nothing about the argument supplied. What about a small change:

   final def withName(s: String): Value = values.find(_.toString == s).getOrElse(
      throw new IllegalArgumentException(s"No value found for $s")

or to stay compatible

   final def withName(s: String): Value = values.find(_.toString == s).getOrElse(
      throw new NoSuchElementException(s"No value found for $s")

however I'm curious if anyone is seriously catching an NoSuchElementException :-)

I've posted this idea on the scala-internas as well:
https://groups.google.com/forum/#!topic/scala-internals/r6nq3s1SZds

@scabug
Copy link
Author

scabug commented Jan 2, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9067?orig=1
Reporter: @Kornel

@scabug
Copy link
Author

scabug commented Jan 2, 2015

@Kornel said:
The PR is here: scala/scala#4229

@scabug scabug closed this as completed Jan 8, 2015
@scabug scabug added this to the 2.11.6 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants