Check for invalid arguments and throw IllegalArgumentException