Example usage for java.lang Throwable toString

List of usage examples for java.lang Throwable toString

Introduction

In this page you can find the example usage for java.lang Throwable toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:eionet.cr.api.xmlrpc.XmlRpcServices.java

@Override
public List dataflowSearch(Map<String, String> criteria) throws CRException {

    if (logger.isInfoEnabled()) {
        logger.info("Entered " + Thread.currentThread().getStackTrace()[1].getMethodName());
    }// www  .  j a  v  a  2 s  .c om

    if (criteria == null) {
        criteria = new HashMap<String, String>();
    }

    if (!criteria.containsKey(Predicates.RDF_TYPE)) {
        criteria.put(Predicates.RDF_TYPE, Subjects.ROD_DELIVERY_CLASS);
    }

    List<DataflowResultDto> result = new ArrayList<DataflowResultDto>();
    try {
        SearchResultDTO<SubjectDTO> searchResult = DAOFactory.get().getDao(SearchDAO.class)
                .searchByFilters(criteria, false, PagingRequest.create(1, MAX_RESULTS), null, null, false);

        String[] strArray = {};
        Collection<SubjectDTO> subjects = searchResult.getItems();
        if (subjects != null) {
            for (Iterator<SubjectDTO> iter = subjects.iterator(); iter.hasNext();) {

                SubjectDTO subjectDTO = iter.next();
                DataflowResultDto resultDTO = new DataflowResultDto();

                resultDTO.setResource(subjectDTO.getUri());
                resultDTO.setTitle(subjectDTO.getObjectValue(Predicates.RDFS_LABEL));

                resultDTO.setDate(subjectDTO.getObjectValue(Predicates.DC_DATE));
                resultDTO.setDataflow(
                        getLiteralValues(subjectDTO, Predicates.ROD_OBLIGATION_PROPERTY).toArray(strArray));
                resultDTO.setLocality(
                        getLiteralValues(subjectDTO, Predicates.ROD_LOCALITY_PROPERTY).toArray(strArray));
                resultDTO.setType(getLiteralValues(subjectDTO, Predicates.RDF_TYPE).toArray(strArray));

                result.add(resultDTO);
            }
        }
    } catch (Throwable t) {
        t.printStackTrace();
        if (t instanceof CRException) {
            throw (CRException) t;
        } else {
            throw new CRException(t.toString(), t);
        }
    }

    return result;
}

From source file:org.callimachusproject.auth.DetachedRealm.java

public void transformErrorPage(String xhtml, Writer writer, String target, String query) throws IOException {
    if (error != null && inError.get() == null && activeErrors.get() < MAX_PRETTY_CONCURRENT_ERRORS) {
        String id = error.getSystemId();
        if (id == null || !id.equals(target)) {
            try {
                inError.set(true);//from   ww w.jav a 2  s  . c om
                activeErrors.incrementAndGet();
                Pipe pb = error.pipeReader(new StringReader(xhtml), target);
                try {
                    pb.passOption("target", target);
                    pb.passOption("query", query);
                    String body = pb.asString();
                    writer.append(body);
                    return;
                } finally {
                    pb.close();
                }
            } catch (Throwable exc) {
                logger.error(exc.toString(), exc);
            } finally {
                inError.remove();
                activeErrors.decrementAndGet();
            }
        }
    }
    writer.write(xhtml);
}

From source file:eionet.cr.harvest.UploadHarvest.java

/**
 * Harvest finished with errors, store relevant metadata for harves source.
 *
 * @param error Error message./*from  w ww .j  a  va  2 s.co  m*/
 * @param noOfTriples number of triples.
 */
private void finishWithError(Throwable error, int noOfTriples) {

    // update context source DTO with the results of this harvest
    getContextSourceDTO().setStatements(noOfTriples);
    getContextSourceDTO().setLastHarvest(new Date());
    getContextSourceDTO().setLastHarvestFailed(error != null);

    // add harvest message about the given error if it's not null
    if (error != null) {
        String message = error.getMessage() == null ? error.toString() : error.getMessage();
        String stackTrace = Util.getStackTrace(error);
        stackTrace = StringUtils.replace(stackTrace, "\r", "");
        addHarvestMessage(message, HarvestMessageType.ERROR, stackTrace);
    }

    // add source metadata resulting from this harvest
    String firstSeen = formatDate(getContextSourceDTO().getTimeCreated());
    String lastRefreshed = formatDate(new Date());

    addSourceMetadata(Predicates.CR_FIRST_SEEN, ObjectDTO.createLiteral(firstSeen, XMLSchema.DATETIME));
    addSourceMetadata(Predicates.CR_LAST_REFRESHED, ObjectDTO.createLiteral(lastRefreshed, XMLSchema.DATETIME));

    if (error != null) {
        addSourceMetadata(Predicates.CR_ERROR_MESSAGE, ObjectDTO.createLiteral(error.toString()));
    }
}

From source file:com.lucidtechnics.blackboard.TargetSpace.java

protected void setErrored(Plan _plan, Throwable _t) {
    getExceptionSet().add(_t.toString());
    int planState = PlanState.setErrored(getPlanState(_plan));
    getPlanStateMap().put(_plan, planState);
    if (getTerminateOnError() == true) {
        setTerminated();//from  w w  w  .j a  v  a 2 s .c om
    }
}

From source file:net.sf.l2j.gameserver.model.entity.L2JOneoRusEvents.FortressSiege.java

/** Searches the list of shuffled players to find if the eventPlayer is one of them */
public static boolean checkShufflePlayers(L2PcInstance eventPlayer) {
    try {/*  ww w  .j  a  va  2  s  . c  o  m*/
        for (L2PcInstance player : _playersShuffle) {
            if (player == null) {
                _playersShuffle.remove(player);
                continue;
            } else if (player.getObjectId() == eventPlayer.getObjectId()) {
                eventPlayer._inEventFOS = true;
                eventPlayer._countFOSKills = 0;
                return true;
            }
            //Just incase a player got a new objectid after DC or reconnect
            else if (player.getName().equals(eventPlayer.getName())) {
                _playersShuffle.remove(player);
                _playersShuffle.add(eventPlayer);
                eventPlayer._inEventFOS = true;
                eventPlayer._countFOSKills = 0;
                return true;
            }
        }
    } catch (Throwable t) {
        _log.error("Error: FortressSiege.checkShufflePlayers: " + t.toString());
    }
    return false;
}

From source file:loci.apps.SlideScannerImport.VentanaScannerInterpreter.java

private void openVentanaImages() {

    try {//w ww .  ja  v a  2s. c  om
        ImporterOptions options = xmlHolder.getOptions();
        options.setSpecifyRanges(true);
        options.setTBegin(0, 0);
        options.setTEnd(0, 0);
        ImportProcess process = new ImportProcess(options);
        if (!process.execute())
            throw new IllegalStateException("Process failed");

        ImagePlusReader reader = new ImagePlusReader(process);
        fullSlideImage = reader.openImagePlus()[0];
        IJ.run(fullSlideImage, "Rotate 90 Degrees Left", "");

        MiniBioformatsTool thumbnailHolder = new MiniBioformatsTool(thumbnailFullPath);
        reader = new ImagePlusReader(thumbnailHolder.getProcess());
        lowresScanImage = reader.openImagePlus()[0];

        thumbnailHolder.close();

    } catch (Throwable e) {
        IJ.log(e.toString());
    }
}

From source file:com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.java

private void validateComputeHostAndStart(Operation startPost, Operation get, Throwable e,
        ProvisionComputeTaskState state) {
    if (e != null) {
        logWarning("Failure retrieving host state (%s): %s", get.getUri(), e.toString());
        startPost.complete();/* w w w. j  a  va 2s . c o  m*/
        failTask(e);
        return;
    }

    ComputeService.ComputeStateWithDescription hostState = get
            .getBody(ComputeService.ComputeStateWithDescription.class);
    if (hostState.description == null) {
        hostState.description = new ComputeDescription();
    }

    if (hostState.description.cpuCount <= 0) {
        hostState.description.cpuCount = 1;
    }

    if (hostState.description.totalMemoryBytes <= 0) {
        hostState.description.totalMemoryBytes = Integer.MAX_VALUE / 4L;
    }

    state.bootAdapterReference = hostState.description.bootAdapterReference;
    state.powerAdapterReference = hostState.description.powerAdapterReference;
    state.instanceAdapterReference = hostState.description.instanceAdapterReference;

    // we can complete start operation now, it will index and cache the
    // update state
    startPost.complete();

    if (state.bootAdapterReference == null ^ state.powerAdapterReference == null) {
        failTask(new IllegalArgumentException("computeHost power and boot need to both be set or empty"));
        return;
    }

    if (state.taskSubStage == ProvisionComputeTaskState.SubStage.CREATING_HOST
            && state.instanceAdapterReference == null) {
        failTask(new IllegalArgumentException("computeHost does not have create service specified"));
        return;
    }

    // now we are ready to start our self-running state machine
    sendSelfPatch(TaskStage.STARTED, state.taskSubStage, null);
}

From source file:geogebra.kernel.statistics.RegressionMath.java

/** Does the Polynom regression for degree > 4*/
public final boolean doPolyN(GeoList gl, int degree) {
    error = false;/*ww  w.  j ava  2s . co  m*/
    geolist = gl;
    size = geolist.size();
    getPoints(); //getPoints from geolist
    if (error) {
        return false;
    }
    try {
        /* Old Jama version:
        long time=System.currentTimeMillis();
        makeMatrixArrays(degree);         //make marray and yarray
        Matrix M=new Matrix(marray);
        Matrix Y=new Matrix(yarray);
        Matrix Par=M.solve(Y);            //Par.print(3,3);
        pararray=Par.getRowPackedCopy();
        System.out.println(System.currentTimeMillis()-time);
        */
        makeMatrixArrays(degree); //make marray and yarray
        RealMatrix M = new Array2DRowRealMatrix(marray, false);
        DecompositionSolver solver = new QRDecompositionImpl(M).getSolver();
        //time=System.currentTimeMillis();
        RealMatrix Y = new Array2DRowRealMatrix(yarray, false);
        RealMatrix P = solver.solve(Y);

        pararray = P.getColumn(0);

        //System.out.println(System.currentTimeMillis()-time);
        //diff(pararray,par);
    } catch (Throwable t) {
        Application.debug(t.toString());
        error = true;
    } //try-catch.  ToDo: A bit more fine-grained error-handling...
    return !error;
}

From source file:com.frontier45.flume.sink.elasticsearch2.ElasticSearchSink.java

@Override
public Status process() throws EventDeliveryException {
    logger.debug("processing...");
    Status status = Status.READY;//from w w w.ja  v a  2s  .co  m
    Channel channel = getChannel();
    Transaction txn = channel.getTransaction();
    try {
        txn.begin();
        int count;
        for (count = 0; count < batchSize; ++count) {
            Event event = channel.take();

            if (event == null) {
                break;
            }
            String realIndexType = BucketPath.escapeString(indexType, event.getHeaders());
            logger.info("elasticsearch-sink2         debug" + event.toString());
            client.addEvent(event, indexNameBuilder, realIndexType, ttlMs);
        }

        if (count <= 0) {
            sinkCounter.incrementBatchEmptyCount();
            counterGroup.incrementAndGet("channel.underflow");
            status = Status.BACKOFF;
        } else {
            if (count < batchSize) {
                sinkCounter.incrementBatchUnderflowCount();
                status = Status.BACKOFF;
            } else {
                sinkCounter.incrementBatchCompleteCount();
            }

            sinkCounter.addToEventDrainAttemptCount(count);
            client.execute();
        }
        txn.commit();
        sinkCounter.addToEventDrainSuccessCount(count);
        counterGroup.incrementAndGet("transaction.success");
    } catch (Throwable ex) {
        try {
            txn.commit();
            sinkCounter.addToEventDrainSuccessCount(batchSize);
            counterGroup.incrementAndGet("transaction.success");
            logger.error(ex.toString());
        } catch (Exception ex2) {
            logger.error("Exception in rollback. Rollback might not have been successful.", ex2);
        }
    } finally {
        txn.close();
    }
    return status;
}