Example usage for org.apache.wicket.util.lang Exceptions findCause

List of usage examples for org.apache.wicket.util.lang Exceptions findCause

Introduction

In this page you can find the example usage for org.apache.wicket.util.lang Exceptions findCause.

Prototype

public static <T extends Throwable> T findCause(final Throwable throwable, final Class<T> causeType) 

Source Link

Document

Looks for a cause of the specified type in throwable's chain

Usage

From source file:org.dcache.webadmin.controller.impl.StandardBillingService.java

License:Open Source License

public List<TimeFrameHistogramData> load(PlotType plotType, TimeFrame timeFrame)
        throws ServiceUnavailableException, NoRouteToCellException, TimeoutCacheException {
    logger.debug("remote fetch of {} {}", plotType, timeFrame);
    List<TimeFrameHistogramData> histograms = new ArrayList<>();
    try {/*from  w ww  .  j a  va2  s  .c om*/
        switch (plotType) {
        case BYTES_READ:
            add(client.getDcBytesHistogram(timeFrame, false), histograms);
            add(client.getHsmBytesHistogram(timeFrame, false), histograms);
            break;
        case BYTES_WRITTEN:
            add(client.getDcBytesHistogram(timeFrame, true), histograms);
            add(client.getHsmBytesHistogram(timeFrame, true), histograms);
            break;
        case BYTES_P2P:
            add(client.getP2pBytesHistogram(timeFrame), histograms);
            break;
        case TRANSFERS_READ:
            add(client.getDcTransfersHistogram(timeFrame, false), histograms);
            add(client.getHsmTransfersHistogram(timeFrame, false), histograms);
            break;
        case TRANSFERS_WRITTEN:
            add(client.getDcTransfersHistogram(timeFrame, true), histograms);
            add(client.getHsmTransfersHistogram(timeFrame, true), histograms);
            break;
        case TRANSFERS_P2P:
            add(client.getP2pTransfersHistogram(timeFrame), histograms);
            break;
        case CONNECTION_TIME:
            add(client.getDcConnectTimeHistograms(timeFrame), histograms);
            break;
        case CACHE_HITS:
            add(client.getHitHistograms(timeFrame), histograms);
            break;
        }
    } catch (UndeclaredThrowableException ute) {
        Throwable cause = Exceptions.findCause(ute, ServiceUnavailableException.class);
        if (cause != null) {
            throw (ServiceUnavailableException) cause;
        }
        cause = Exceptions.findCause(ute, NoRouteToCellException.class);
        if (cause != null) {
            throw (NoRouteToCellException) cause;
        }
        cause = Exceptions.findCause(ute, TimeoutCacheException.class);
        if (cause != null) {
            throw (TimeoutCacheException) cause;
        }
        cause = ute.getCause();
        Throwables.propagateIfPossible(cause);
        throw new RuntimeException(
                "Unexpected error: " + "this is probably a bug. Please report " + "to the dCache team.", cause);
    }
    return histograms;
}

From source file:org.hippoecm.frontend.RepositoryRuntimeExceptionHandlingRequestCycleListener.java

License:Apache License

@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex) {
    IRequestHandler handler = null;/*  w ww  .  j  ava2s. c  om*/
    RepositoryRuntimeException rrEx = Exceptions.findCause(ex, RepositoryRuntimeException.class);

    if (rrEx != null) {
        handler = createRequestHandler(rrEx);

        if (handler != null) {
            clearStates();
        }
    }

    return handler;
}