/** * Return the exception simple message without including the expression * that caused the failure. * @since 4.0 */ public String getSimpleMessage() { return super.getMessage(); }
public JpaSystemException(RuntimeException ex) { super(ex.getMessage(), ex); }
/** * 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(); }
/** * 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()); }
/** * 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()); }
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); } } }
@Override public DataAccessException translateExceptionIfPossible(RuntimeException ex) { if (ex instanceof PersistenceException) { return new DataAccessResourceFailureException(ex.getMessage()); } return null; } }
@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; } }
@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; } }
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(); }
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(); }
@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()); } }
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); } } }
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); } } }
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()); } }
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()); } }
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()); } }
@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()); }
@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()); }
@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()); }