/** * @return First exception in the causes list if it is checked or it is supported by client, null otherwise */ @Nullable @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"}) public Exception getFirstCauseException() { if (!causes.isEmpty()) { Throwable t = causes.get(0).getThrowable(); if (t != null) { if (!(t instanceof RuntimeException) && !(t instanceof Error)) { return (Exception) t; } if (!(t instanceof Error) && t.getClass().getAnnotation(SupportedByClient.class) != null) return (Exception) t; } } return null; }
if (!re.getCauses().isEmpty()) { RemoteException.Cause cause = re.getCauses().get(re.getCauses().size() - 1); if (cause.getThrowable() != null) { rootCause = cause.getThrowable(); } else {
protected Throwable removeRemoteException(Throwable throwable) { if (throwable instanceof RemoteException) { RemoteException re = (RemoteException) throwable; for (int i = re.getCauses().size() - 1; i >= 0; i--) { if (re.getCauses().get(i).getThrowable() != null) { return re.getCauses().get(i).getThrowable(); } } } return throwable; }
List<RemoteException.Cause> causes = ((RemoteException) rootCause).getCauses(); RemoteException.Cause cause = causes.get(causes.size() - 1); msg = cause.getThrowable() != null ? cause.getThrowable().toString() : cause.getClassName() + ": " + cause.getMessage(); } else { msg = rootCause.toString();
@Override public boolean handle(Throwable exception, UiContext context) { List<Throwable> list = ExceptionUtils.getThrowableList(exception); for (Throwable throwable : list) { if (classNames.contains(throwable.getClass().getName()) && canHandle(throwable.getClass().getName(), throwable.getMessage(), throwable)) { doHandle(throwable.getClass().getName(), throwable.getMessage(), throwable, context); return true; } if (throwable instanceof RemoteException) { RemoteException remoteException = (RemoteException) throwable; for (RemoteException.Cause cause : remoteException.getCauses()) { if (classNames.contains(cause.getClassName()) && canHandle(cause.getClassName(), cause.getMessage(), cause.getThrowable())) { doHandle(cause.getClassName(), cause.getMessage(), cause.getThrowable(), context); return true; } } } } return false; }
@Override public boolean handle(Throwable exception, WindowManager windowManager) { List<Throwable> list = ExceptionUtils.getThrowableList(exception); for (Throwable throwable : list) { if (classNames.contains(throwable.getClass().getName()) && canHandle(throwable.getClass().getName(), throwable.getMessage(), throwable)) { doHandle(throwable.getClass().getName(), throwable.getMessage(), throwable, windowManager); return true; } if (throwable instanceof RemoteException) { RemoteException remoteException = (RemoteException) throwable; for (RemoteException.Cause cause : remoteException.getCauses()) { if (classNames.contains(cause.getClassName()) && canHandle(cause.getClassName(), cause.getMessage(), cause.getThrowable())) { doHandle(cause.getClassName(), cause.getMessage(), cause.getThrowable(), windowManager); return true; } } } } return false; }
public WebTimer() { component = new Label(); timerImpl = new CubaTimer(); timerImpl.setExceptionHandler(e -> { int reIdx = ExceptionUtils.indexOfType(e, RemoteException.class); if (reIdx > -1) { RemoteException re = (RemoteException) ExceptionUtils.getThrowableList(e).get(reIdx); for (RemoteException.Cause cause : re.getCauses()) { if (cause.getThrowable() instanceof NoUserSessionException) { log.warn("NoUserSessionException in timer {}, timer will be stopped", timerImpl.getLoggingTimerId()); stop(); break; } } } else if (ExceptionUtils.indexOfThrowable(e, NoUserSessionException.class) > -1) { log.warn("NoUserSessionException in timer {}, timer will be stopped", timerImpl.getLoggingTimerId()); stop(); } throw new RuntimeException("Exception in timer", e); }); }
@Override public boolean handle(ErrorEvent event, App app) { Throwable exception = event.getThrowable(); List<Throwable> list = ExceptionUtils.getThrowableList(exception); for (Throwable throwable : list) { if (classNames.contains(throwable.getClass().getName()) && canHandle(throwable.getClass().getName(), throwable.getMessage(), throwable)) { doHandle(app, throwable.getClass().getName(), throwable.getMessage(), throwable); return true; } if (throwable instanceof RemoteException) { RemoteException remoteException = (RemoteException) throwable; for (RemoteException.Cause cause : remoteException.getCauses()) { if (classNames.contains(cause.getClassName()) && canHandle(cause.getClassName(), cause.getMessage(), cause.getThrowable())) { doHandle(app, cause.getClassName(), cause.getMessage(), cause.getThrowable()); return true; } } } } return false; }