Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java

private void initMediaPlayer() {
    String PATH_TO_FILE = voice6;
    mediaPlayer = new MediaPlayer();

    try {//from  ww w  .j  av  a  2  s .co m
        mediaPlayer.setDataSource(PATH_TO_FILE);
        mediaPlayer.prepare();
        if (isInDebugMode)
            Toast.makeText(this, PATH_TO_FILE, Toast.LENGTH_LONG).show();
        stateMediaPlayer = stateMP_NotStarter;
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
        stateMediaPlayer = stateMP_Error;
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
        stateMediaPlayer = stateMP_Error;
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
        stateMediaPlayer = stateMP_Error;
    }
}

From source file:com.mobsandgeeks.saripaar.Validator.java

private View getView(Field field) {
    try {/*from ww  w  . j a  v a2 s.c  om*/
        field.setAccessible(true);
        Object instance = null;

        if (mActivity != null) {
            instance = mActivity;
        } else if (mSupportFragment != null) {
            instance = mSupportFragment;
        }
        return (View) field.get(instance);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:gbc.jtimecalc.AbstractTimeDifferenceCalculatorTest.java

protected void assertCorrectMessages() {

    Method[] methods = this.getClass().getMethods();
    Object[] args = null;//from   w ww  .  jav a 2 s .c  o m

    for (Method method : methods) {
        if (isTestMethod(method)) {
            logger.debug("Invoking " + method.getName() + "(): ");
            try {
                method.invoke(this, args);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            } catch (InvocationTargetException e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }

            boolean omitTailingZeroes = false;
            if (method.getName().endsWith("WithoutTailingZeroes")) {
                omitTailingZeroes = true;
            }

            boolean onlyBusinessDays = false;
            if (method.getName().contains("BusinessDay")) {
                onlyBusinessDays = true;
            }

            boolean businessDaysInString = onlyBusinessDays;

            assertCorrectMessage(getExpectedValue(), getEndTime(), getStartTime(), omitTailingZeroes,
                    onlyBusinessDays, null, businessDaysInString);
        }
    }
}

From source file:com.controlj.experiment.bacnet.servlets.DiscoveryServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentType("application/json");
    final PrintWriter writer = resp.getWriter();
    final String id = req.getParameter("id");
    final String type = req.getParameter("type");
    final JSONArray arrayData = new JSONArray();

    try {// w  ww .j ava  2 s. c  om
        if (type == null) {
            // Hard Coded root
            JSONObject root = new JSONObject();
            root.put("title", "Networks");
            root.put("childtype", "networks");
            root.put("isLazy", true);
            root.put("icon", getIconForType(LocationType.System));
            arrayData.put(root);
        } else {
            // not root, need to get access to BACnet
            BACnetConnection conn = BACnet.getBACnet().getDefaultConnection();
            BACnetAccess bacnet = conn.getAccess();

            if (type != null && type.equals("networks")) { // handle network discovery

                NetworkDiscoverer networkDiscoverer = bacnet.createNetworkDiscoverer();
                List<Integer> addresses = networkDiscoverer.search(5, TimeUnit.SECONDS);
                addresses.add(0);

                Collections.sort(addresses);
                for (Integer address : addresses) {
                    JSONObject next = new JSONObject();
                    next.put("title", address == 0 ? "local" : Integer.toString(address));
                    next.put("id", address);
                    next.put("childtype", "devices");
                    next.put("icon", getIconForType(LocationType.Network));
                    next.put("isLazy", true);
                    next.put("renderpage", "network.jsp");
                    arrayData.put(next);
                }
            } else if (type != null && type.equals("devices") && id != null) {
                DeviceDiscoverer deviceDiscoverer = bacnet.createDeviceDiscoverer();
                int netNum = Integer.parseInt(id);

                List<BACnetDevice> devices = deviceDiscoverer.search(netNum, 5, TimeUnit.SECONDS);

                for (BACnetDevice device : devices) {
                    JSONObject next = new JSONObject();

                    next.put("title", Integer.toString(device.getDeviceIdentifier().getInstance()));
                    next.put("id", device.getDeviceIdentifier().getInstance());
                    next.put("childtype", "objects");
                    next.put("icon", getIconForType(LocationType.Device));
                    next.put("isLazy", true);
                    arrayData.put(next);
                }
            } else if (type != null && type.equals("objects") && id != null) {
                int devId = Integer.parseInt(id);
                BACnetDevice device = bacnet.lookupDevice(devId).get();
                List<BACnetObjectIdentifier> objectIDs = device.readObjectIdentifiers().get();

                for (BACnetObjectIdentifier objectID : objectIDs) {
                    try {
                        if (supportedObjectTypes.containsKey(objectID.getType())) {

                            BACnetString name = device.readProperty(objectID, ScheduleDefinition.objectName)
                                    .get();

                            JSONObject next = new JSONObject();
                            next.put("title",
                                    name.getValue() + " - " + Integer.toString(objectID.getInstance()));
                            next.put("devid", devId);
                            next.put("id", objectID.getObjectId());
                            next.put("icon", getIconForType(LocationType.Microblock));
                            next.put("renderpage", supportedObjectTypes.get(objectID.getType()));
                            next.put("isLazy", false);
                            arrayData.put(next);
                        }
                    } catch (IllegalArgumentException e) {
                    } // was a custom type that I can't handle, ignore
                }
            }
        }

        arrayData.write(writer);

    } catch (Exception e) {
        // since this servlet is being accessed via XHR and a user won't see it, this seems the best
        // way to communicate (and log) errors.
        e.printStackTrace();
    }

}

From source file:edu.drake.research.android.lipswithmaps.activity.MapsActivity.java

@Override
@SuppressWarnings({ "MissingPermission" })
protected void onStop() {
    try {// w  ww  .  j a  v a2  s .c o m
        unregisterReceiver(mWifiScanReceiver);
    } catch (java.lang.IllegalArgumentException e) {
        Log.e(TAG, "onStop: ", e);
        e.printStackTrace();
    }
    if (mLocationManager != null) {
        //do not put permission here it will end up in an infinite loop
        mLocationManager.removeUpdates(mLocationListener);
    }

    if (mSensorManager != null) {
        mSensorManager.unregisterListener(this);
    }
    if (mAuthListener != null) {
        mAuth.removeAuthStateListener(mAuthListener);
    }
    super.onStop();
}

From source file:info.mtgdb.api.Card.java

/**
 * Construct Card from JSON text. If the JSON doesn't describe a 
 * Card, the only indication would likely be all of the data members
 * of the new Card containing default values.
 * //from ww  w.jav a 2  s .c o m
 * @param json A {@link JSONObject} that hopefully describes a Card.
 */
public Card(JSONObject json) {
    this();
    @SuppressWarnings("unchecked")
    Set<String> set = json.keySet();
    for (String s : set) {
        CardField cardField = memberTypeHash.get(s.toLowerCase());
        if (cardField != null) {
            //System.out.println(s+" is a "+cardField.type);
            try {
                if (cardField.type.matches("int")) {
                    int val = json.getInt(s);
                    cardField.f.set(this, val);
                } else if (cardField.type.matches("boolean")) {
                    boolean val = json.getBoolean(s);
                    cardField.f.set(this, val);
                } else if (cardField.type.matches("java.lang.String")) {
                    Object o = json.get(s);
                    if (o != JSONObject.NULL)
                        cardField.f.set(this, (String) o);
                    else
                        continue;
                } else if (cardField.type.matches("java.util.Date")) {
                    Object o = json.get(s);
                    if (o == null) {
                        cardField.f.set(this, null);
                        continue;
                    }
                    Date date = dateFormatterInput.parse((String) o);
                    cardField.f.set(this, date);
                } else if (cardField.type.matches("java.util.List")) {
                    JSONArray jsonArray = json.getJSONArray(s);
                    if (s.matches("colors")) {
                        colors = new ArrayList<String>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            colors.add(jsonArray.getString(i));
                        }
                    } else if (s.matches("rulings")) {
                        rulings = new ArrayList<Ruling>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            Ruling r = new Ruling(jsonArray.getJSONObject(i));
                            rulings.add(r);
                        }
                    } else if (s.matches("formats")) {
                        formats = new ArrayList<Format>();
                        for (int i = 0; i < jsonArray.length(); i++) {
                            Format f = new Format(jsonArray.getJSONObject(i));
                            formats.add(f);
                        }
                    }
                }
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
                /*} catch (ParseException e) {
                   e.printStackTrace();
                   System.err.println("s = "+s);
                   System.err.println("CardField = "+cardField.type);*/
            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("s = " + s);
                System.err.println("CardField = " + cardField.type);
            }
        }
        //else System.out.println(s+" wasn't found.");
    }
}

From source file:com.samsung.richnotification.RichNotification.java

@Override
public void onDestroy() {
    super.onDestroy();
    if (richRemoteInputReceiver != null) {
        try {//from   www.ja  va  2s .c  o  m
            this.cordova.getActivity().unregisterReceiver(richRemoteInputReceiver);
            richRemoteInputReceiver = null;
        } catch (IllegalArgumentException e) {
            //not an error case
            if (Log.isLoggable(RICHNOTI, Log.DEBUG))
                Log.d(TAG, "unregistering receiver in onDestroy: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

From source file:com.jpeterson.littles3.S3ObjectRequestTest.java

/**
 * Test a <code>create</code> with an invalid request.
 *//*from  ww w  . java 2 s  .co m*/
public void xtest_createIllegalRequest() {
    Mock mockHttpServletRequest = mock(HttpServletRequest.class);

    mockHttpServletRequest.expects(once()).method("getPathInfo").will(returnValue("/foo"));
    mockHttpServletRequest.expects(once()).method("getHeader").with(eq("Host")).will(returnValue("localhost"));
    mockHttpServletRequest.expects(once()).method("getRequestURL")
            .will(returnValue(new StringBuffer("http://localhost/context/bar")));

    try {
        HackAuthenticator authenticator = new HackAuthenticator();
        authenticator.setAuthenticator(new S3Authenticator());

        S3ObjectRequest.create((HttpServletRequest) mockHttpServletRequest.proxy(), "localhost", authenticator);
        fail("Expected exception");
    } catch (IllegalArgumentException e) {
        // expected
    } catch (AuthenticatorException e) {
        e.printStackTrace();
        fail("Unexpected exception");
        return;
    }
}

From source file:edu.mit.media.funf.funfohmage.OhmageLoginActivity.java

private void onLoginTaskDone(OhmageApi.AuthenticateResponse response, final String username) {

    try {//from   w ww  .j a  va2  s .  c  om
        dismissDialog(DIALOG_LOGIN_PROGRESS);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "Attempting to dismiss dialog that had not been shown.");
        e.printStackTrace();
    }

    switch (response.getResult()) {
    case SUCCESS:
        Log.i(TAG, "login success");
        final String hashedPassword = response.getHashedPassword();

        //Funf Ohmage: Since no camplaigns needed
        /*
        if(Config.IS_SINGLE_CAMPAIGN) {
           // Download the single campaign
           showDialog(DIALOG_DOWNLOADING_CAMPAIGNS);
                
           // Temporarily set the user credentials. If the download fails, they will be removed
           // We need to set this so the ResponseSyncService can use them once the campaign is downloaded
           mPreferencesHelper.putUsername(username);
           mPreferencesHelper.putHashedPassword(hashedPassword);
                
           mCampaignDownloadTask.setCredentials(username, hashedPassword);
           mCampaignDownloadTask.forceLoad();
        } else {
           loginFinished(username, hashedPassword);
        }*/
        loginFinished(username, hashedPassword);
        break;
    case FAILURE:
        Log.e(TAG, "login failure");
        for (String s : response.getErrorCodes()) {
            Log.e(TAG, "error code: " + s);
        }

        //clear creds
        //mPreferencesHelper.clearCredentials();
        //just clear password, keep username for single user lock-in
        // FAISAL: commenting this out so the user gets a chance to back out of a password change attempt
        /*mPreferencesHelper.putHashedPassword("");*/

        //clear password so user will re-enter it
        mPasswordEdit.setText("");

        //show error dialog
        if (Arrays.asList(response.getErrorCodes()).contains("0201")) {
            mPreferencesHelper.setUserDisabled(true);
            showDialog(DIALOG_USER_DISABLED);
        } else {
            showDialog(DIALOG_LOGIN_ERROR);
        }
        break;
    case HTTP_ERROR:
        Log.e(TAG, "login http error");

        //show error dialog
        showDialog(DIALOG_NETWORK_ERROR);
        break;
    case INTERNAL_ERROR:
        Log.e(TAG, "login internal error");

        //show error dialog
        showDialog(DIALOG_INTERNAL_ERROR);
        break;
    }
}

From source file:org.apache.hadoop.hive.metastore.MetaStoreClient.java

public MetaStoreClient(Configuration configuration) throws MetaException {
    if (configuration == null) {
        configuration = new HiveConf(MetaStoreClient.class);
    }/*  ww w  .  j  a  v  a2 s.  com*/

    wh = new Warehouse(configuration);

    if (HiveConf.getVar(configuration, HiveConf.ConfVars.METASTOREURIS) != null) {
        String metastoreUrisString[] = HiveConf.getVar(configuration, HiveConf.ConfVars.METASTOREURIS)
                .split(",");
        this.metastoreUris = new URI[metastoreUrisString.length];
        try {
            int i = 0;
            for (String s : metastoreUrisString) {
                URI tmpUri = new URI(s.trim());
                if (tmpUri.getScheme() == null) {
                    throw new IllegalArgumentException("URI: " + s + " does not have a scheme");
                }
                this.metastoreUris[i++] = tmpUri;

            }
        } catch (IllegalArgumentException e) {
            throw (e);
        } catch (Exception e) {
            System.err.println("Exception getting uri to connect to the store with: " + e.getMessage());
            e.printStackTrace();
        }
    } else if (HiveConf.getVar(configuration, HiveConf.ConfVars.METASTOREDIRECTORY) != null) {
        this.metastoreUris = new URI[1];
        try {
            this.metastoreUris[0] = new URI(
                    HiveConf.getVar(configuration, HiveConf.ConfVars.METASTOREDIRECTORY));
        } catch (URISyntaxException e) {
            System.err.println("Exception getting uri to connect to the store with: " + e.getMessage());
            e.printStackTrace();
        }
    } else {
        System.err.println("NOT getting uris from conf");
        throw new RuntimeException("MetaStoreURIs not found in conf file");
    }
    this.conf = configuration;
    transport = null;
    client = null;
    open = false;
}