Example usage for java.lang Exception getStackTrace

List of usage examples for java.lang Exception getStackTrace

Introduction

In this page you can find the example usage for java.lang Exception getStackTrace.

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:controllers.CensusController.java

@RequestMapping(value = "/registerUser", method = RequestMethod.GET)
public ModelAndView addUser(@RequestParam int censusId, @CookieValue("user") String username) {
    ModelAndView result = null;//from   w  ww  .j  a  v a  2 s .com
    try {

        censusService.addUserToOpenedCensus(censusId, username);
        result = new ModelAndView("redirect:/census/getCensusesToRegister.do");

    } catch (Exception oops) {
        result = new ModelAndView("redirect:/census/getCensusesToRegister.do");
        result.addObject("message", "error");
        JOptionPane.showMessageDialog(null, "Error");
        oops.getStackTrace();
    }

    return result;
}

From source file:com._17od.upm.gui.OptionsDialog.java

private void okButtonAction() {
    try {//from   ww w. j ava2  s .c om
        if (databaseAutoLockCheckbox.isSelected()) {
            if (databaseAutoLockTime.getText() == null || databaseAutoLockTime.getText().trim().equals("")
                    || !Util.isNumeric(databaseAutoLockTime.getText())) {
                JOptionPane.showMessageDialog(OptionsDialog.this,
                        Translator.translate("invalidValueForDatabaseAutoLockTime"),
                        Translator.translate("problem"), JOptionPane.ERROR_MESSAGE);
                databaseAutoLockTime.requestFocusInWindow();
                return;
            }
        }

        if (accountPasswordLength.getText() == null || accountPasswordLength.getText().trim().equals("")
                || !Util.isNumeric(accountPasswordLength.getText())) {
            JOptionPane.showMessageDialog(OptionsDialog.this,
                    Translator.translate("invalidValueForAccountPasswordLength"),
                    Translator.translate("problem"), JOptionPane.ERROR_MESSAGE);
            databaseAutoLockTime.requestFocusInWindow();
            return;
        }

        Preferences.set(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP, dbToLoadOnStartup.getText());
        Preferences.set(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD,
                String.valueOf(hideAccountPasswordCheckbox.isSelected()));
        Preferences.set(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK,
                String.valueOf(databaseAutoLockCheckbox.isSelected()));
        Preferences.set(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK_TIME, databaseAutoLockTime.getText());
        Preferences.set(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH,
                accountPasswordLength.getText());
        Preferences.set(Preferences.ApplicationOptions.HTTPS_ACCEPT_SELFSIGNED_CERTS,
                String.valueOf(acceptSelfSignedCertsCheckbox.isSelected()));
        Preferences.set(Preferences.ApplicationOptions.HTTP_PROXY_HOST, httpProxyHost.getText());
        Preferences.set(Preferences.ApplicationOptions.HTTP_PROXY_PORT, httpProxyPort.getText());
        Preferences.set(Preferences.ApplicationOptions.HTTP_PROXY_USERNAME, httpProxyUsername.getText());
        String encodedPassword = new String(
                Base64.encodeBase64(new String(httpProxyPassword.getPassword()).getBytes()));
        Preferences.set(Preferences.ApplicationOptions.HTTP_PROXY_PASSWORD, encodedPassword);
        Preferences.set(Preferences.ApplicationOptions.HTTP_PROXY_ENABLED,
                String.valueOf(enableProxyCheckbox.isSelected()));

        // Save the new language and set a flag if it has changed
        String beforeLocale = Preferences.get(Preferences.ApplicationOptions.LOCALE);
        Locale selectedLocale = Translator.SUPPORTED_LOCALES[localeComboBox.getSelectedIndex()];
        String afterLocale = selectedLocale.getLanguage();
        if (!afterLocale.equals(beforeLocale)) {
            Preferences.set(Preferences.ApplicationOptions.LOCALE, selectedLocale.getLanguage());
            Translator.loadBundle(selectedLocale);
            languageChanged = true;
        }

        Preferences.save();
        setVisible(false);
        dispose();
        okClicked = true;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(parentFrame, e.getStackTrace(), Translator.translate("error"),
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:controllers.CensusController.java

@RequestMapping(value = "/addUser", method = RequestMethod.GET)
public ModelAndView addUser(@RequestParam int censusId, @CookieValue("user") String username,
        @RequestParam String usernameAdd) {
    ModelAndView result = new ModelAndView("census/misVotaciones");
    try {//w  w w  .j av  a 2s . co  m

        censusService.addUserToClosedCensus(censusId, username, usernameAdd);
        result = new ModelAndView("redirect:/census/edit.do?censusId=" + censusId);

    } catch (Exception oops) {
        result = new ModelAndView("redirect:/census/edit.do?censusId=" + censusId);
        result.addObject("message", "error");
        JOptionPane.showMessageDialog(null, "Error");
        oops.getStackTrace();
    }

    return result;
}

From source file:controllers.CensusController.java

@RequestMapping(value = "/removeUser", method = RequestMethod.GET)
public ModelAndView removeUser(@RequestParam int censusId, @CookieValue("user") String username,
        @RequestParam String usernameRemove) {
    ModelAndView result = null;/*  w ww.  j  a v a2  s  .  co  m*/
    try {

        censusService.removeUserOfClosedCensus(censusId, username, usernameRemove);

        result = new ModelAndView("redirect:/census/edit.do?censusId=" + censusId);

    } catch (Exception oops) {
        result = new ModelAndView("redirect:/census/edit.do?censusId=" + censusId);
        result.addObject("message", "error");
        JOptionPane.showMessageDialog(null, "Error");
        oops.getStackTrace();
    }

    return result;
}

From source file:edu.rice.cs.bioinfo.programs.phylonet.algos.network.NetworkPseudoLikelihoodFromGTT.java

protected double computeProbability(Network<Object> speciesNetwork, List allTriplets,
        Map<String, List<String>> species2alleles, List tripleFrequencies) {
    /*//from   w ww  . j  a v a 2s .  c om
    GeneTreeProbabilityPseudo likelihood = new GeneTreeProbabilityPseudo();
    double prob = likelihood.computePseudoLikelihood(speciesNetwork, tripleFrequencies);
    */
    GeneTreeProbabilityPseudo calculator = new GeneTreeProbabilityPseudo();
    if (_numThreads != 0) {
        int batchSize = allTriplets.size() / _numThreads;
        if (allTriplets.size() % _numThreads != 0) {
            batchSize++;
        }
        calculator.setBatchSize(batchSize);
    }
    calculator.initialize(speciesNetwork);
    double[][] probs = new double[allTriplets.size()][3];
    Thread[] myThreads = new Thread[_numThreads];
    //System.out.println(speciesNetwork);
    if (_numThreads > 1) {
        calculator.setParallel(true);
        for (int i = 0; i < _numThreads; i++) {
            myThreads[i] = new MyThread(speciesNetwork, calculator, allTriplets, probs);
            myThreads[i].start();
        }
        for (int i = 0; i < _numThreads; i++) {
            try {
                myThreads[i].join();
            } catch (InterruptedException ignore) {
            }
        }
    } else {
        try {
            calculator.computePseudoLikelihood(speciesNetwork, allTriplets, probs);
        } catch (Exception e) {
            System.out.println(speciesNetwork);
            System.err.println(e.getMessage());
            e.getStackTrace();
            System.exit(-1);

        }
    }
    double totalProb = calculateFinalLikelihood(probs, tripleFrequencies);
    //System.out.println(speciesNetwork);
    //System.out.println(totalProb);
    return totalProb;
}

From source file:edu.rice.cs.bioinfo.programs.phylonet.algos.network.InferMLNetworkFromSequences.java

private Network networkNew2Old(DirectedGraphToGraphAdapter<String, PhyloEdge<String>> speciesNetwork) {
    Network<Object> bniNetwork = null;
    try {//from w w  w .j a  v  a 2s  . co  m

        String networkString = network2String(speciesNetwork);
        bniNetwork = edu.rice.cs.bioinfo.programs.phylonet.structs.network.util.Networks
                .readNetwork(networkString);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.getStackTrace();
    }
    return bniNetwork;
}

From source file:com.esri.geoevent.solutions.processor.geometry.QueryReportProcessor.java

private com.esri.core.geometry.Geometry constructGeometry(com.esri.ges.spatial.Geometry geo) throws Exception {
    try {/*from w  w  w .  j  a va2 s.com*/
        String jsonIn = geo.toJson();
        JsonFactory jf = new JsonFactory();
        JsonParser jp = jf.createJsonParser(jsonIn);
        MapGeometry mgeo = GeometryEngine.jsonToGeometry(jp);
        com.esri.core.geometry.Geometry geoIn = mgeo.getGeometry();
        return GeometryEngine.project(geoIn, srIn, srBuffer);
    } catch (Exception e) {
        LOG.error(e.getMessage());
        LOG.error(e.getStackTrace());
        throw (e);
    }
}

From source file:com.bstek.dorado.idesupport.resolver.RobotResolver.java

protected void assembleError(Document document, Element responseElement, Exception error) {
    String message = error.getMessage();
    if (message == null) {
        message = error.getClass().getSimpleName();
    }/*  w  w  w .  j a  va  2  s . co m*/
    Element messageElement = document.createElement("Message");
    messageElement.appendChild(document.createTextNode(message));
    responseElement.appendChild(messageElement);

    Element stackTraceElement = document.createElement("StackTrace");
    responseElement.appendChild(stackTraceElement);

    StackTraceElement[] stackTrace = error.getStackTrace();
    for (StackTraceElement ste : stackTrace) {
        Element element = document.createElement("Element");
        element.setAttribute("className", ste.getClassName());
        element.setAttribute("methodName", ste.getMethodName());
        element.setAttribute("fileName", ste.getFileName());
        element.setAttribute("lineNumber", String.valueOf(ste.getLineNumber()));
        stackTraceElement.appendChild(element);
    }
}

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

public static void showArtifactHtml(L2PcInstance eventPlayer, String objectId) {
    if (eventPlayer == null)
        return;//from   www  .  ja  v a 2 s  . co m
    try {
        NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
        TextBuilder replyMSG = new TextBuilder("<html><head><body><center>");
        replyMSG.append("Sacred Artifact<br><br>");
        replyMSG.append("<font color=\"00FF00\">" + _eventName + " Artifact</font><br1>");
        if (eventPlayer._teamNameFOS != null && eventPlayer._teamNameFOS.equals(_teams.get(1)))
            replyMSG.append("<font color=\"LEVEL\">This is your Sacred Artifact. Defend it!</font><br1>");
        else
            replyMSG.append(
                    "<font color=\"LEVEL\">Use the Seal Of Ruler Skill to Complete this Siege!</font><br1>");
        if (!_started)
            replyMSG.append("The Siege is not in progress yet.<br>Wait for a Admin/GM to start the event.<br>");
        replyMSG.append("</center></body></html>");
        adminReply.setHtml(replyMSG.toString());
        eventPlayer.sendPacket(adminReply);
    } catch (Exception e) {
        _log.error("FOS Engine[showArtifactHtml(" + eventPlayer.getName() + ", " + objectId + ")]: exception: "
                + e.getStackTrace());
    }
}

From source file:com.carvoyant.modularinput.Program.java

@Override
protected String stackTraceToLogEntry(Exception e) {
    // Concatenate all the lines of the exception's stack trace with \\ between them.
    StringBuilder sb = new StringBuilder();

    sb.append("\"");
    sb.append(e.getClass().getName());/* ww  w.j a v a2 s . c om*/

    if (e.getMessage() != null) {
        sb.append(": ");
        sb.append(e.getMessage());
    }

    sb.append("\" at ");
    for (StackTraceElement s : e.getStackTrace()) {
        sb.append(s.toString());
        sb.append("\\\\");
    }
    return sb.toString();
}