Extract value from exception

I get a NumberFormatException and I want to get the value from the exception itself, which looks like enter image description here

But for the value, there are no getters available, can anyone suggest any solution to extract that value, not reflection, or even reflection can be perfect.

+4
source share
2 answers

org.springframework.beans.TypeMismatchException Object getValue(), , :

...
} catch(Exception exception) {
   if(exception instanceof TypeMismatchException) {
      Object value = ((TypeMismatchException) exp).getValue;
      ... // what you want to do with value
   }
}

...
} catch(TypeMismatchException exception) {
      Object value = exp.getValue;
      ... // what you want to do with value
}

org.springframework.beans.TypeMismatchException

package org.springframework.beans;
public class TypeMismatchException extends PropertyAccessException {
...
    /**
     * Return the offending value (may be {@code null})
     */
    @Override
    public Object getValue() {
        return this.value;
    }
...
}
+2

Source: https://habr.com/ru/post/1619485/


All Articles