Missing method getRawMessage for ContextedException and ContextedRuntimeException (LANG-737).

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1153271 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joerg Schaible 2011-08-02 21:04:35 +00:00
parent 2b5f7a79b0
commit f761a82212
5 changed files with 38 additions and 2 deletions

View File

@ -226,11 +226,21 @@ public String getMessage(){
return getFormattedExceptionMessage(super.getMessage());
}
/**
* Provides the message explaining the exception without the contextual data.
*
* @see java.lang.Throwable#getMessage()
* @return the message
* @since 3.0.1
*/
public String getRawMessage() {
return super.getMessage();
}
/**
* {@inheritDoc}
*/
public String getFormattedExceptionMessage(String baseMessage) {
return exceptionContext.getFormattedExceptionMessage(baseMessage);
}
}

View File

@ -226,6 +226,17 @@ public String getMessage(){
return getFormattedExceptionMessage(super.getMessage());
}
/**
* Provides the message explaining the exception without the contextual data.
*
* @see java.lang.Throwable#getMessage()
* @return the message
* @since 3.0.1
*/
public String getRawMessage() {
return super.getMessage();
}
/**
* {@inheritDoc}
*/

View File

@ -35,6 +35,7 @@
<action type="add" issue="LANG-730">EnumSet -&gt; bit vector</action>
<action type="fix" issue="LANG-734">The CHAR_ARRAY cache in CharUtils duplicates the cache in java.lang.Character</action>
<action type="update" issue="LANG-735">Deprecate CharUtils.toCharacterObject(char) in favor of java.lang.Character.valueOf(char)</action>
<action type="add" issue="LANG-737">Missing method getRawMessage for ContextedException and ContextedRuntimeException</action>
</release>
<release version="3.0" date="2011-07-18" description="Backwards incompatible update of Commons Lang to Java 5">

View File

@ -88,4 +88,11 @@ public void testNullExceptionPassing() {
assertTrue(message != null);
}
public void testRawMessage() {
assertEquals(Exception.class.getName() + ": " + TEST_MESSAGE, exceptionContext.getRawMessage());
exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
assertEquals(TEST_MESSAGE_2, exceptionContext.getRawMessage());
exceptionContext = new ContextedException(null, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
assertNull(exceptionContext.getRawMessage());
}
}

View File

@ -22,7 +22,6 @@
/**
* JUnit tests for ContextedRuntimeException.
*
*/
public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<ContextedRuntimeException> {
@ -88,4 +87,12 @@ public void testNullExceptionPassing() {
String message = exceptionContext.getMessage();
assertTrue(message != null);
}
public void testRawMessage() {
assertEquals(Exception.class.getName() + ": " + TEST_MESSAGE, exceptionContext.getRawMessage());
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
assertEquals(TEST_MESSAGE_2, exceptionContext.getRawMessage());
exceptionContext = new ContextedRuntimeException(null, new Exception(TEST_MESSAGE), new DefaultExceptionContext());
assertNull(exceptionContext.getRawMessage());
}
}