I want to do this instead of a null pointer exception in a java method return new ResponseEntity<String>(HttpStatus.BAD_REQUEST); but my method returns an int not a string. The main thing I want to do is return a 400 Status code. What can I do?
I tried throw new IllegalArgumentException(arg + "is not a valid argument; positive value expected"); but that returns a 500 status code with a good message. I'm doing this on a web service if that helps.
I also tried return new ResponseEntity<Integer>(HttpStatus.BAD_REQUEST);, but that doesn't seem to work either.