Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

In this page you can find the example usage for java.lang RuntimeException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:de.mkrtchyan.recoverytools.RashrActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    isDark = Common.getBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_DARK_UI);
    setTheme(!isDark ? R.style.Rashr : R.style.Rashr_Dark);
    setContentView(R.layout.loading_layout);

    final TextView tvLoading = (TextView) findViewById(R.id.tvLoading);

    final Thread StartThread = new Thread(new Runnable() {
        @Override//from w w w. ja  v a2 s  . co m
        public void run() {
            mActivity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    tvLoading.setText(R.string.getting_root);
                }
            });
            /** Try to get root access */
            try {
                startShell();
                mToolbox = new Toolbox(mShell);
            } catch (IOException e) {
                mActivity.addError(Constants.RASHR_TAG, e, false);
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        findViewById(R.id.pbLoading).setVisibility(View.INVISIBLE);
                        tvLoading.setTextColor(Color.RED);
                        tvLoading.setText(R.string.no_root);
                    }
                });
                return;
            }

            /** Creating needed folder and unpacking files */
            mActivity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    tvLoading.setText(R.string.loading_data);
                }
            });
            for (File i : Folder) {
                if (!i.exists()) {
                    if (!i.mkdir()) {
                        mActivity.addError(Constants.RASHR_TAG, new IOException(i + " can't be created!"),
                                false);
                    }
                }
            }
            try {
                extractFiles();
            } catch (IOException e) {
                mActivity.addError(Constants.RASHR_TAG, e, true);
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(mContext, R.string.failed_unpack_files, Toast.LENGTH_LONG).show();
                    }
                });
            }

            try {
                File LogCopy = new File(mContext.getFilesDir(), Constants.LastLog.getName() + ".txt");
                mToolbox.setFilePermissions(Constants.LastLog, "666");
                mToolbox.copyFile(Constants.LastLog, LogCopy, false, false);
            } catch (Exception e) {
                LastLogExists = false;
                mActivity.addError(Constants.RASHR_TAG, e, false);
            }
            mActivity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    tvLoading.setText(R.string.reading_device);
                }
            });
            if (mDevice == null)
                mDevice = new Device(mActivity);

            /** If device is not supported, you can report it now or close the App */
            if (!mDevice.isRecoverySupported() && !mDevice.isKernelSupported()) {
                mActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        showDeviceNotSupportedDialog();
                    }
                });
            } else {
                Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_SHOW_UNIFIED, true);
                if (!Common.getBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_FIRST_RUN)) {
                    /** Setting first start configuration */
                    Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_ADS, true);
                    Common.setBooleanPref(mContext, Shell.PREF_NAME, Shell.PREF_LOG, true);
                    Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_CHECK_UPDATES,
                            true);
                    mActivity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            showUsageWarning();
                        }
                    });
                } else {
                    /** Checking if version has changed */
                    try {
                        PackageInfo pInfo;
                        String pName;
                        PackageManager pManager;
                        if ((pName = getPackageName()) != null && (pManager = getPackageManager()) != null
                                && (pInfo = pManager.getPackageInfo(pName, 0)) != null) {
                            final int previous_version = Common.getIntegerPref(mContext, Constants.PREF_NAME,
                                    Constants.PREF_KEY_CUR_VER);
                            final int current_version = pInfo.versionCode;
                            mVersionChanged = current_version > previous_version;
                            Common.setIntegerPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_CUR_VER,
                                    current_version);
                            mActivity.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    checkUpdates(current_version);
                                }
                            });
                        } else {
                            mVersionChanged = true;
                        }
                    } catch (PackageManager.NameNotFoundException e) {
                        mActivity.addError(Constants.RASHR_TAG, e, false);
                        mVersionChanged = true;
                    }
                    if (mVersionChanged) {
                        /** Re-enable Ads */
                        Common.setBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_ADS, true);
                        /** Reset Shell Logs */
                        Common.deleteLogs(mContext);
                        /** Show Play Store rater dialog */
                        mActivity.runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                if (!Common.getBooleanPref(mContext, Constants.PREF_NAME,
                                        Constants.PREF_KEY_HIDE_RATER)) {
                                    Notifyer.showAppRateDialog(mContext, Constants.PREF_NAME,
                                            Constants.PREF_KEY_HIDE_RATER);
                                }
                            }
                        });
                    }
                }
            }
            mActivity.runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    try {
                        setContentView(R.layout.activity_rashr);
                        mToolbar = (Toolbar) findViewById(R.id.toolbar);
                        setSupportActionBar(mToolbar);
                        mDevice.downloadUtils(mContext);
                        mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
                                .findFragmentById(R.id.navigation_drawer);
                        mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
                                (DrawerLayout) findViewById(R.id.RashrLayout));

                        AdView ads = (AdView) findViewById(R.id.ads);
                        if (ads != null) {
                            if (Common.getBooleanPref(mContext, Constants.PREF_NAME, Constants.PREF_KEY_ADS)) {
                                ads.loadAd(new AdRequest().addTestDevice("0559BC4D133A29D00A36F3FE8FECD883"));
                            }
                        }
                        onNavigationDrawerItemSelected(0);
                    } catch (NullPointerException e) {
                        mActivity.addError(Constants.RASHR_TAG, e, false);
                        try {
                            tvLoading.setText(R.string.failed_setup_layout);
                            tvLoading.setTextColor(Color.RED);
                        } catch (RuntimeException ex) {
                            mActivity.addError(Constants.RASHR_TAG, e, true);
                            ex.printStackTrace();

                        }
                    }
                }
            });
        }
    });
    StartThread.start();
}

From source file:org.beangle.struts2.action.EntityDrivenAction.java

/**
 * ?/*from  w w w  .  j  ava2  s.  c o m*/
 * @return
 */
public String importData() {
    TransferResult tr = new TransferResult();
    EntityImporter importer = buildEntityImporter();
    if (null == importer) {
        return redirect("importForm", "XLS!");
    }
    configImporter(importer);
    try {
        importer.transfer(tr);
        if (importerListener != null) {
            put("count", importerListener.getCount());
            put("ucount", importerListener.getUcount());
        }
        put("importResult", tr);
    } catch (RuntimeException e) {
        // ?
        tr.addFailure("<font style='color:red;font-size:14px'>?!</font>", "");
        e.printStackTrace();
    } catch (Exception e) {
        // ?
        e.printStackTrace();
    }
    return forward("result");
}

From source file:pct.droid.fragments.BaseVideoPlayerFragment.java

public void onSubtitleLanguageSelected(String language) {
    if (mCurrentSubsLang != null && (language == null || mCurrentSubsLang.equals(language))) {
        return;/* w  w w .j a  v a2 s  . c o  m*/
    }

    showTimedCaptionText(null);

    mCurrentSubsLang = language;

    if (language.equals("no-subs")) {
        mSubs = null;
        return;
    }

    SubsProvider.download(getActivity(), mMedia, language, new com.squareup.okhttp.Callback() {
        @Override
        public void onFailure(Request request, IOException e) {
            mSubs = null;
            mCurrentSubsLang = "no-subs";

            try {
                Toast.makeText(getActivity(), "Subtitle download failed", Toast.LENGTH_SHORT).show();
            } catch (RuntimeException runtimeException) {
                runtimeException.printStackTrace();
            }
        }

        @Override
        public void onResponse(Response response) throws IOException {
            mSubsFile = new File(SubsProvider.getStorageLocation(getActivity()),
                    mMedia.videoId + "-" + mCurrentSubsLang + ".srt");
            startSubtitles();
        }
    });
}

From source file:org.universAAL.itests.IntegrationTest.java

/**
 * This method returns sorted list of bundles which will be started for the
 * purpose of the TestCase. Method parses launch configuration provided in
 * the constructor and extracts pax run arguments as well as JVM arguments.
 * JVM arguments are then set by means of java.lang.System class. The
 * "bundles.configuration.location" JVM argument provided in the launch
 * configuration is ignored and the "bundlesConfLocation" property is used
 * instead./*from   w w  w.  jav a  2s  .com*/
 *
 * @return Returns array of resources.
 */
@Override
protected Resource[] getTestBundles() {
    try {
        setDefaults();
        prepareClassesToTests();
        Resource[] testBundles = null;
        if (eclipseLaunchFile != null) {
            testBundles = insertNeededDeps(processEclipseLaunhFile());
        } else {
            testBundles = insertNeededDeps(processPaxArtifactUrls());
        }
        log("Following bundles are going to be installed in itests framework:");
        int i = 1;
        for (Resource bundle : testBundles) {
            log(i++ + ". " + bundle.getDescription());
        }
        return testBundles;
    } catch (RuntimeException ex) {
        ex.printStackTrace();
        throw ex;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }
}

From source file:org.webguitoolkit.ui.controls.Page.java

@Override
protected void endHTML(PrintWriter out) {
    try {//from w  w  w .  j  av  a 2 s .c  o m
        StringBuffer contexts = new StringBuffer();
        // get all the chages which are collectable until now.
        ContextElement[] chg = calculateContextChange();
        ContextElement aktChg;
        for (int i = 0; i < chg.length; i++) {
            aktChg = chg[i];
            if (aktChg.getCssId().startsWith(getId() + ".append")) {
                out.println(aktChg.getValue());
            } else {
                // collect all changes in an array
                contexts.append("ctx[ctx.length] = { cssId: \"" + aktChg.getCssId() + "\", value:"
                        + JSUtil.wrApoEsc(aktChg.getValue()) + ", type:\"" + aktChg.getType() + "\", status:\""
                        + aktChg.getStatus() + "\"};\n\r");
            }
        }

        // now is the latest time to define out onload context elements
        // applyContext({1:{ cssId: "contextSize", value:"force", type:"txt", status:"n"}})
        out.println("<script type=\"text/javascript\">");
        out.println("function loadOnInit() {");
        out.println("var ctx = new Array();");
        out.println(contexts.toString());
        // to manually process it in owrk-loop for processing context elements.
        out.println("applyContext(ctx);");
        out.println("}</script>");
        out.print("</BODY>");

        if (DWRCallback.debug) {
            // debug
            // log the events to monitor
            IDataBag bag = WebGuiFactory.getInstance().createDataBag(this);
            bag.addProperty("time", new Date());
            bag.addProperty("inbound", new ContextElement[] {});
            bag.addProperty("outbound", chg);
            bag.addProperty("source", getId());
            bag.addProperty("type", "html");
            bag.addProperty("duration", (System.currentTimeMillis() - start) + "ms.");
            DWRCallback.contextLog.add(0, bag);
            // debug ende
        }

    } catch (RuntimeException ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.sun.japex.ChartGenerator.java

private int generateTestCaseBarCharts(String baseName, String extension) {
    int nOfFiles = 0;
    List<DriverImpl> driverInfoList = _testSuite.getDriverInfoList();

    // Get number of tests from first driver
    final int nOfTests = driverInfoList.get(0).getAggregateTestCases().size();

    int groupSizesIndex = 0;
    int[] groupSizes = calculateGroupSizes(nOfTests, _plotGroupSize);

    try {//from w w w .  j  a  v a  2 s .c  o  m
        String resultUnit = _testSuite.getParam(Constants.RESULT_UNIT);
        String resultUnitX = _testSuite.getParam(Constants.RESULT_UNIT_X);

        // Ensure japex.resultUnitX is not null
        if (resultUnitX == null) {
            resultUnitX = "";
        }

        // Find first normalizer driver (if any)
        DriverImpl normalizerDriver = null;
        for (DriverImpl di : driverInfoList) {
            if (di.isNormal()) {
                normalizerDriver = di;
                break;
            }
        }

        // Check if normalizer driver can be used as such
        if (normalizerDriver != null) {
            if (normalizerDriver.getDoubleParamNoNaN(Constants.RESULT_ARIT_MEAN) == 0.0
                    || normalizerDriver.getDoubleParamNoNaN(Constants.RESULT_GEOM_MEAN) == 0.0
                    || normalizerDriver.getDoubleParamNoNaN(Constants.RESULT_HARM_MEAN) == 0.0) {
                normalizerDriver = null;
            } else {
                resultUnit = "% of " + resultUnit;
                if (resultUnitX != null) {
                    resultUnitX = "% of " + resultUnitX;
                }
            }
        }

        // Generate charts 
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        DefaultCategoryDataset datasetX = new DefaultCategoryDataset();

        boolean hasValueX = false;

        int i = 0, thisGroupSize = 0;
        for (; i < nOfTests; i++) {

            for (DriverImpl di : driverInfoList) {
                TestCaseImpl tc = (TestCaseImpl) di.getAggregateTestCases().get(i);

                // User normalizer driver if defined
                if (normalizerDriver != null) {
                    TestCaseImpl normalTc = (TestCaseImpl) normalizerDriver.getAggregateTestCases().get(i);

                    dataset.addValue(
                            normalizerDriver == di ? 100.0
                                    : (100.0 * tc.getDoubleParamNoNaN(Constants.RESULT_VALUE)
                                            / normalTc.getDoubleParamNoNaN(Constants.RESULT_VALUE)),
                            _plotDrivers ? tc.getName() : di.getName(),
                            _plotDrivers ? di.getName() : tc.getName());

                    if (tc.hasParam(Constants.RESULT_VALUE_X)) {
                        datasetX.addValue(
                                (100.0 * tc.getDoubleParamNoNaN(Constants.RESULT_VALUE_X)
                                        / normalTc.getDoubleParamNoNaN(Constants.RESULT_VALUE_X)),
                                _plotDrivers ? tc.getName() : di.getName(),
                                _plotDrivers ? di.getName() : tc.getName());
                        hasValueX = true;
                    }
                } else {
                    dataset.addValue(tc.getDoubleParamNoNaN(Constants.RESULT_VALUE),
                            _plotDrivers ? tc.getName() : di.getName(),
                            _plotDrivers ? di.getName() : tc.getName());

                    if (tc.hasParam(Constants.RESULT_VALUE_X)) {
                        datasetX.addValue(tc.getDoubleParamNoNaN(Constants.RESULT_VALUE_X),
                                _plotDrivers ? tc.getName() : di.getName(),
                                _plotDrivers ? di.getName() : tc.getName());
                        hasValueX = true;
                    }
                }

            }

            thisGroupSize++;

            // Generate chart for this group if complete
            if (thisGroupSize == groupSizes[groupSizesIndex]) {
                int nextPlotIndex = 1;
                CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot();

                // Use same renderer in combine charts to get same colors
                BarRenderer3D renderer = new BarRenderer3D();
                renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());

                // Bar chart for secondary data set based on japex.resultValueX
                if (hasValueX) {
                    NumberAxis rangeAxisX = new NumberAxis(resultUnitX);
                    CategoryPlot subplotX = new CategoryPlot(datasetX, null, rangeAxisX, renderer);

                    // Set transparency and clear legend for this plot
                    subplotX.setForegroundAlpha(0.7f);
                    subplotX.setFixedLegendItems(new LegendItemCollection());

                    plot.add(subplotX, nextPlotIndex++);
                    _chartHeight += 50; // Adjust chart height
                }

                // Bar chart for main data set based on japex.resultValue
                NumberAxis rangeAxis = new NumberAxis(resultUnit);
                CategoryPlot subplot = new CategoryPlot(dataset, null, rangeAxis, renderer);
                subplot.setForegroundAlpha(0.7f); // transparency
                plot.add(subplot, nextPlotIndex);

                // Create chart and save it as JPEG
                String chartTitle = _plotDrivers ? "Results per Driver" : "Results per Test";
                JFreeChart chart = new JFreeChart(
                        hasValueX ? chartTitle : (chartTitle + "(" + resultUnit + ")"),
                        new Font("SansSerif", Font.BOLD, 14), plot, true);
                chart.setAntiAlias(true);
                ChartUtilities.saveChartAsJPEG(new File(baseName + Integer.toString(nOfFiles) + extension),
                        chart, _chartWidth, _chartHeight);

                nOfFiles++;
                groupSizesIndex++;
                thisGroupSize = 0;

                // Create fresh data sets
                dataset = new DefaultCategoryDataset();
                datasetX = new DefaultCategoryDataset();
            }
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return nOfFiles;
}

From source file:commonSession.PersistAttivitaFacadeBean.java

public Boolean saveMerge(Object obj) throws Exception {

    try {/*w ww.j a  v a 2s .c  o  m*/

        //      TerrEm.merge(obj);
        GestionaleEm.merge(obj);

        return true;

    } catch (RuntimeException e) {

        e.printStackTrace();

    }

    return false;

}

From source file:tv.teads.teadssdkdemo.utils.external.PagerSlidingTabStrip.java

@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    if (pager != null) {
        if (adapterObserver.isAttached()) {
            try {
                pager.getAdapter().unregisterDataSetObserver(adapterObserver);
                adapterObserver.setAttached(false);
            } catch (RuntimeException e) {
                e.printStackTrace();
            }/*from w ww  .j a v  a  2 s  .  c  o m*/
        }
    }
}

From source file:com.connectsdk.service.AirPlayService.java

private long parseTimeValueFromString(String value) {
    long duration = 0L;
    try {//  w  w  w  .jav  a2s . c  om
        float f = Float.valueOf(value);
        duration = (long) f * 1000;
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
    return duration;
}

From source file:com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartFragmentAdapter.java

@Override
public void update(DataClientInterface dataClient, DataConsumerInterface.InsertCallback iCallback) {

    Pair<OHLC, Time> pricePair = dataClient.getLast(_symbol, DataClientLocalDebug.DATA_PRICE_DEF);
    Pair<Integer, Time> volPair = dataClient.getLast(_symbol, DataClientLocalDebug.DATA_VOL_DEF);

    OHLC price = new OHLC(pricePair.first);
    int vol = volPair.first.intValue();
    Time time = new Time(pricePair.second);

    /* if we've rolled past TIME_GRANULARITY */
    if (_hasSegment.get() && _segHasRolled(_lastGranularSegTime, time, DataClientInterface.TIME_GRANULARITY)) {
        iCallback.insertRow(//from  w  ww . j a  va2  s.  c  o  m
                _createContentValues(_lastGranularPriceSeg, _lastGranularVolSeg, _lastGranularSegTime), _symbol,
                (DataConsumerInterface) this);

        _lastGranularSegTime = _truncateTime(time, GMS, true, false); /*
                                                                      Log.d("Data-Consumer-Update-DB", 
                                                                      _lastGranularSegTime.format("%H:%M:%S")
                                                                      );   */
    }
    _lastGranularPriceSeg = new OHLC(price);
    _lastGranularVolSeg = vol;

    if (!_streamReady.get() || _myCursor == null) {
        _updateTime.set(time);
        return;
    }
    /* Log.d("Data-Consumer-Update-Current", 
    _lastPriceSeg.toString() + "    "
    + String.valueOf(_lastVolSeg) + "   " 
    +time.format("%H:%M:%S"));            */

    if (price.high > _highPrice) {
        _highPrice = price.high;
        Intent iii = new Intent(HighLowChange.NEW_HIGH_PRICE);
        iii.putExtra(HighLowChange.EXTRA_VALUE, price.high);
        iii.putExtra(HighLowChange.FRAGMENT_ID, MY_ID);
        _localBcastMngr.sendBroadcast(iii);
    }
    if (price.low < _lowPrice) {
        _lowPrice = price.low;
        Intent iii = new Intent(HighLowChange.NEW_LOW_PRICE);
        iii.putExtra(HighLowChange.EXTRA_VALUE, price.low);
        iii.putExtra(HighLowChange.FRAGMENT_ID, MY_ID);
        _localBcastMngr.sendBroadcast(iii);
    }

    try { /* remember vol is cumm. vis-a-vis the granular seg */
        _mainSgmnt.update(_getBucketIndex(price.close), vol);
    } catch (RuntimeException e) { //DEBUG
        Log.d("UPDATE EXCEPTION", "::BEGIN:: " + e.getMessage());
        e.printStackTrace();
        Log.d("UPDATE EXCEPTION", "::END:: " + e.getMessage());
    }

    /* high volume is checked in the panel, where it is agglomerated */

    _updateTime.set(time);
}