What exception to throw in Java?

  • A+
Category:Languages

Let's say I've got a map from Football team -> enum (e.g., "Barcelona FC" -> FootballTeam.BARCELONA). What exception should I throw if some team is not there?

I'm thinking about RuntimeException vs IllegalArgumentException but neither of them fits in here.


NoSuchElementException:

Thrown by various accessor methods to indicate that the element being requested does not exist.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: