Changed a custom exception to an illegal argument exception as per @shoftee's comments.