Closes #574 by throwing RestException subclasses instead of IllegalStateException.