Weird output of Throwable getMessage()

Posted by Ravi Gupta on Stack Overflow See other posts from Stack Overflow or by Ravi Gupta
Published on 2010-03-12T12:17:26Z Indexed on 2010/03/12 12:27 UTC
Read the original article Hit count: 274

Filed under:
|
|

Hi I have below pseudo code with throws an exception like this

throw new MyException("Bad thing happened","com.stuff.errorCode");

where MyException extends Exception class. So the problem is when I try to get the message from MyException class by calling myEx.getMessage() it returns

???en_US.Bad thing happened???

instead of my original message i.e. Bad thing happened

I have checked that MyException class doesn't overrides Throwable class's getMessage() behavior.

Below is the how the call passes from MyException.getMessage() to Throwable.getMessage()

public MyException(String msg, String sErrorCode){
super(msg);
this.sErrorCode = sErrorCode;
this.iSeverity = 0;

}

which then calls

public Exception(String message) {
super(message);
}

and finally

   public Throwable(String message) {
    fillInStackTrace();
    detailMessage = message;
}

when I do a getMessage on myexception it calls Throwable's getMessage as below

 public String getMessage() {
    return detailMessage;
}

So ideally it should return the original message as I set when throwing the exception. What's the ???en_US thing ?

© Stack Overflow or respective owner

Related posts about java

Related posts about exception