本文整理了Java中java.lang.Exception.getMessage()
方法的一些代码示例,展示了Exception.getMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exception.getMessage()
方法的具体详情如下:
包路径:java.lang.Exception
类名称:Exception
方法名:getMessage
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
public String handleException(Exception exception) {
return exception.getMessage();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public String handleException(Exception exception) {
return exception.getMessage();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public String handleException(Exception exception) {
return exception.getMessage();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public final void afterPropertiesSet() throws IllegalArgumentException, BeanInitializationException {
if (this.jmsTemplate == null) {
throw new IllegalArgumentException("'connectionFactory' or 'jmsTemplate' is required");
}
try {
initGateway();
}
catch (Exception ex) {
throw new BeanInitializationException("Initialization of JMS gateway failed: " + ex.getMessage(), ex);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@ExceptionHandler(Exception.class)
@ResponseBody
public String handleException(Exception exception) {
return exception.getMessage();
}
}
代码示例来源:origin: spring-projects/spring-framework
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public String errorHandler(Exception e) {
return e.getMessage();
}
代码示例来源:origin: spring-projects/spring-framework
@ExceptionHandler
public ModelAndView handle(Exception ex) throws IOException {
return new ModelAndView("errorView", "detail", ex.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
@ExceptionHandler(Exception.class)
@ResponseBody
public String handleException(Exception exception) {
return exception.getMessage();
}
}
代码示例来源:origin: spring-projects/spring-framework
private Object readResolved(Type resolvedType, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
Reader reader = getReader(inputMessage);
try {
return readInternal(resolvedType, reader);
}
catch (Exception ex) {
throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex, inputMessage);
}
}
代码示例来源:origin: spring-projects/spring-framework
public void testCheckedThrowableSync(CacheableService<?> service) throws Exception {
String arg = UUID.randomUUID().toString();
try {
service.throwCheckedSync(arg);
fail("Excepted exception");
}
catch (Exception ex) {
ex.printStackTrace();
assertEquals("Wrong exception type", IOException.class, ex.getClass());
assertEquals(arg, ex.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
public void testCheckedThrowable(CacheableService<?> service) throws Exception {
String arg = UUID.randomUUID().toString();
try {
service.throwChecked(arg);
fail("Excepted exception");
}
catch (Exception ex) {
assertEquals("Wrong exception type", IOException.class, ex.getClass());
assertEquals(arg, ex.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onCompleteFailure() {
AtomicReference<Throwable> onError = new AtomicReference<Throwable>();
try {
OBSERVER_ONCOMPLETED_FAIL(onError).onComplete();
fail("expects exception to be thrown");
} catch (Exception e) {
assertNull(onError.get());
assertTrue(e instanceof SafeObserverTestException);
assertEquals("onCompleteFail", e.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onNextFailure() {
AtomicReference<Throwable> onError = new AtomicReference<Throwable>();
try {
OBSERVER_ONNEXT_FAIL(onError).onNext("one");
fail("expects exception to be thrown");
} catch (Exception e) {
assertNull(onError.get());
assertTrue(e instanceof SafeSubscriberTestException);
assertEquals("onNextFail", e.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onCompleteFailure() {
AtomicReference<Throwable> onError = new AtomicReference<Throwable>();
try {
OBSERVER_ONCOMPLETED_FAIL(onError).onComplete();
fail("expects exception to be thrown");
} catch (Exception e) {
assertNull(onError.get());
assertTrue(e instanceof SafeSubscriberTestException);
assertEquals("onCompleteFail", e.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onNextFailure() {
AtomicReference<Throwable> onError = new AtomicReference<Throwable>();
try {
OBSERVER_ONNEXT_FAIL(onError).onNext("one");
fail("expects exception to be thrown");
} catch (Exception e) {
assertNull(onError.get());
assertTrue(e instanceof SafeObserverTestException);
assertEquals("onNextFail", e.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onNextOnErrorFailure() {
try {
OBSERVER_ONNEXT_ONERROR_FAIL().onNext("one");
fail("expects exception to be thrown");
} catch (Exception e) {
e.printStackTrace();
assertTrue(e instanceof SafeObserverTestException);
assertEquals("onNextFail", e.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onNextOnErrorFailure() {
try {
OBSERVER_ONNEXT_ONERROR_FAIL().onNext("one");
fail("expects exception to be thrown");
} catch (Exception e) {
e.printStackTrace();
assertTrue(e instanceof SafeSubscriberTestException);
assertEquals("onNextFail", e.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
private void checkNumber(String expression, Object value, Class<?> type) {
try {
SpelExpressionParser parser = new SpelExpressionParser();
SpelExpression expr = parser.parseRaw(expression);
Object exprVal = expr.getValue();
assertEquals(value, exprVal);
assertEquals(type, exprVal.getClass());
}
catch (Exception ex) {
fail(ex.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onErrorFailure() {
try {
subscriberOnErrorFail().onError(new SafeSubscriberTestException("error!"));
fail("expects exception to be thrown");
} catch (Exception e) {
assertTrue(e instanceof SafeSubscriberTestException);
assertEquals("onErrorFail", e.getMessage());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void onErrorFailure() {
try {
OBSERVER_ONERROR_FAIL().onError(new SafeObserverTestException("error!"));
fail("expects exception to be thrown");
} catch (Exception e) {
assertTrue(e instanceof SafeObserverTestException);
assertEquals("onErrorFail", e.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!