Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Java exception should I use?

Tags:

java

exception

Let's assume I'm a complete lazy bum and I don't want to invest the several dozen keystrokes needed for my own exception class (it's not utterly important which gets used, really). However, to pretend I'm following good practices here, I want a pre-existing one that best fits my situation.

Problem: I need to throw an exception when my class's constructor receives an object in its parameters that is not found within a given list I've built elsewhere.

Which exception class would be appropriate to throw for that?

like image 503
Daddy Warbox Avatar asked Nov 26 '22 23:11

Daddy Warbox


1 Answers

IllegalArgumentException

like image 96
Chris Jester-Young Avatar answered Dec 29 '22 15:12

Chris Jester-Young