本文整理了Java中java.lang.RuntimeException.getMessage()
方法的一些代码示例,展示了RuntimeException.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RuntimeException.getMessage()
方法的具体详情如下:
包路径:java.lang.RuntimeException
类名称:RuntimeException
方法名:getMessage
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the exception simple message without including the expression
* that caused the failure.
* @since 4.0
*/
public String getSimpleMessage() {
return super.getMessage();
}
代码示例来源:origin: spring-projects/spring-framework
public JpaSystemException(RuntimeException ex) {
super(ex.getMessage(), ex);
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* 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();
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Provides the message explaining the exception, including the contextual data.
*
* @see java.lang.Throwable#getMessage()
* @return the message, never null
*/
@Override
public String getMessage(){
return getFormattedExceptionMessage(super.getMessage());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the detail message, including the message from the nested exception
* if there is one.
*/
@Override
@Nullable
public String getMessage() {
return NestedExceptionUtils.buildMessage(super.getMessage(), getCause());
}
代码示例来源:origin: apache/incubator-dubbo
void serialize(AbstractHessianOutput out, Object obj, Field field)
throws IOException {
Object value = null;
try {
value = field.get(obj);
} catch (IllegalAccessException e) {
log.log(Level.FINE, e.toString(), e);
}
try {
out.writeObject(value);
} catch (RuntimeException e) {
throw new RuntimeException(e.getMessage() + "\n Java field: " + field,
e);
} catch (IOException e) {
throw new IOExceptionWrapper(e.getMessage() + "\n Java field: " + field,
e);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
if (ex instanceof PersistenceException) {
return new DataAccessResourceFailureException(ex.getMessage());
}
return null;
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
try {
return invoker.invoke(invocation);
} catch (RuntimeException e) {
logger.error("Got unchecked and undeclared exception which called by " + RpcContext.getContext().getRemoteHost()
+ ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName()
+ ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e);
throw e;
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
try {
return invoker.invoke(invocation);
} catch (RuntimeException e) {
logger.error("Got unchecked and undeclared exception which called by " + RpcContext.getContext().getRemoteHost()
+ ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName()
+ ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e);
throw e;
}
}
代码示例来源:origin: libgdx/libgdx
public String getMessage () {
if (trace == null) return super.getMessage();
StringBuilder sb = new StringBuilder(512);
sb.append(super.getMessage());
if (sb.length() > 0) sb.append('\n');
sb.append("Serialization trace:");
sb.append(trace);
return sb.toString();
}
代码示例来源:origin: libgdx/libgdx
public String getMessage () {
if (trace == null) return super.getMessage();
StringBuilder sb = new StringBuilder(512);
sb.append(super.getMessage());
if (sb.length() > 0) sb.append('\n');
sb.append("Serialization trace:");
sb.append(trace);
return sb.toString();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testServiceIsAdvised() {
ClassPathXmlApplicationContext ctx =
new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass());
service = (Service) ctx.getBean("service");
try {
this.service.serveMe();
fail("service operation has not been advised by transaction interceptor");
}
catch (RuntimeException ex) {
assertEquals("advice invoked",ex.getMessage());
}
}
代码示例来源:origin: prestodb/presto
public void assertFails(@Language("SQL") String sql, @Language("RegExp") String expectedMessageRegExp)
{
try {
runner.execute(runner.getDefaultSession(), sql).toTestTypes();
fail(format("Expected query to fail: %s", sql));
}
catch (RuntimeException exception) {
if (!nullToEmpty(exception.getMessage()).matches(expectedMessageRegExp)) {
fail(format("Expected exception message '%s' to match '%s' for query: %s", exception.getMessage(), expectedMessageRegExp, sql), exception);
}
}
}
代码示例来源:origin: prestodb/presto
private static void assertCreateConnectorFails(String metastoreUri, String exceptionString)
{
try {
assertCreateConnector(metastoreUri);
fail("expected connector creation to fail:" + metastoreUri);
}
catch (RuntimeException e) {
assertContains(e.getMessage(), exceptionString);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
public void testUncheckedThrowable(CacheableService<?> service) throws Exception {
try {
service.throwUnchecked(1L);
fail("Excepted exception");
}
catch (RuntimeException ex) {
assertEquals("Wrong exception type", UnsupportedOperationException.class, ex.getClass());
assertEquals("1", ex.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
public void testUncheckedThrowableSync(CacheableService<?> service) throws Exception {
try {
service.throwUncheckedSync(1L);
fail("Excepted exception");
}
catch (RuntimeException ex) {
assertEquals("Wrong exception type", UnsupportedOperationException.class, ex.getClass());
assertEquals("1", ex.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
protected void assertException(
Method method, String pointcut, String returning, String throwing, Class<?> exceptionType, String message) {
AspectJAdviceParameterNameDiscoverer discoverer = new AspectJAdviceParameterNameDiscoverer(pointcut);
discoverer.setRaiseExceptions(true);
discoverer.setReturningName(returning);
discoverer.setThrowingName(throwing);
try {
discoverer.getParameterNames(method);
fail("Expecting " + exceptionType.getName() + " with message '" + message + "'");
}
catch (RuntimeException expected) {
assertEquals("Expecting exception of type " + exceptionType.getName(),
exceptionType, expected.getClass());
assertEquals("Exception message does not match expected", message, expected.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGroovyBeanInterface() {
context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName()+"-groovy-interface-context.xml");
TestService bean = context.getBean("groovyBean", TestService.class);
LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
assertEquals(0, logAdvice.getCountThrows());
try {
bean.sayHello();
fail("Expected exception");
}
catch (RuntimeException ex) {
assertEquals("GroovyServiceImpl", ex.getMessage());
}
assertEquals(1, logAdvice.getCountThrows());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testJavaBean() {
context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName()+"-java-context.xml");
TestService bean = context.getBean("javaBean", TestService.class);
LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
assertEquals(0, logAdvice.getCountThrows());
try {
bean.sayHello();
fail("Expected exception");
}
catch (RuntimeException ex) {
assertEquals("TestServiceImpl", ex.getMessage());
}
assertEquals(1, logAdvice.getCountThrows());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testGroovyBeanDynamic() {
context = new GenericXmlApplicationContext(getClass(), getClass().getSimpleName()+"-groovy-dynamic-context.xml");
TestService bean = context.getBean("groovyBean", TestService.class);
LogUserAdvice logAdvice = context.getBean(LogUserAdvice.class);
assertEquals(0, logAdvice.getCountThrows());
try {
bean.sayHello();
fail("Expected exception");
}
catch (RuntimeException ex) {
assertEquals("GroovyServiceImpl", ex.getMessage());
}
// No proxy here because the pointcut only applies to the concrete class, not the interface
assertEquals(0, logAdvice.getCountThrows());
assertEquals(0, logAdvice.getCountBefore());
}
内容来源于网络,如有侵权,请联系作者删除!