Example usage for java.lang Error Error

List of usage examples for java.lang Error Error

Introduction

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

Prototype

public Error(Throwable cause) 

Source Link

Document

Constructs a new error with the specified cause and a detail message of (cause==null ?

Usage

From source file:com.hs.mail.security.login.JndiLoginModule.java

@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
        Map<String, ?> options) {
    super.initialize(subject, callbackHandler, sharedState, options);
    contextFactory = getOption("context.factory", "com.sun.jndi.ldap.LdapCtxFactory");
    url = getOption("url", null);
    if (url == null) {
        throw new Error("No JNDI URL specified");
    }//from  w  ww.  j ava  2s .  c o m
    username = getOption("username", null);
    password = getOption("password", null);
    authentication = getOption("authentication", "simple");
    base = getOption("base", null);
    String filter = getOption("searchFilter", "(uid={0})");
    searchFilterFormat = new MessageFormat(filter);
    returnAttribute = getOption("returnAttribute", null);
    subtree = new Boolean(getOption("subtree", "true")).booleanValue();
}

From source file:cn.com.loopj.android.http.SaxAsyncHttpResponseHandler.java

/**
 * Constructs new SaxAsyncHttpResponseHandler with given handler instance
 *
 * @param t instance of Handler extending DefaultHandler
 * @see DefaultHandler//  ww  w. ja v a  2 s  .c o  m
 */
public SaxAsyncHttpResponseHandler(T t) {
    super();
    if (t == null) {
        throw new Error("null instance of <T extends DefaultHandler> passed to constructor");
    }
    this.handler = t;
}

From source file:com.fortydegree.ra.data.POIDownloader.java

public void download(Location l, int radius, int maxResults, final CallBack<List<Marker>> places)
        throws WebServiceException {

    List<String> parameters = Arrays.asList("latitude", Double.toString(l.getLatitude()), "longitude",
            Double.toString(l.getLongitude()), "radius", Integer.toString(radius), "max",
            Integer.toString(maxResults));

    this.downloader.download(parameters, new CallBack<String>() {
        public void execute(String input) {
            try {
                if (input != null && input.length() > 0) {
                    List<Marker> list = JsonUnmarshaller.load(new JSONObject(input));
                    places.execute(list);
                }/*from   w  w w  .ja v a2 s  . com*/
            } catch (JSONException e) {
                Log.e(TAG, e.getMessage(), e);
                throw new Error(e);// should not happen
            }
        }
    }, new CallBack<Throwable>() {
        public void execute(Throwable input) {
            Log.e(TAG, input.getMessage(), input);

        }
    });

}

From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForClassTag.java

public int doStartTag() {
    try {/*from  w w  w. j ava  2  s. co  m*/
        VitroRequest vreq = new VitroRequest((HttpServletRequest) pageContext.getRequest());
        WebappDaoFactory wdf = vreq.getWebappDaoFactory();
        if (wdf == null)
            throw new Exception("could not get WebappDaoFactory from request.");

        VClass vclass = wdf.getVClassDao().getVClassByURI(getClassUri());
        if (vclass == null)
            throw new Exception("could not get class for " + getClassUri());

        List<Individual> individuals = wdf.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1,
                -1);

        JspWriter out = pageContext.getOut();

        for (Individual ind : individuals) {
            String uri = ind.getURI();
            if (uri != null) {
                out.print("<option value=\"" + StringEscapeUtils.escapeHtml(uri) + '"');
                if (uri.equals(getSelectedUri()))
                    out.print(" selected=\"selected\"");
                out.print('>');
                out.print(StringEscapeUtils.escapeHtml(ind.getName()));
                out.println("</option>");
            }

        }
    } catch (Exception ex) {
        throw new Error("Error in doStartTag: " + ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:com.aionemu.commons.database.DatabaseFactory.java

public synchronized static void init(String configFilePath) {
    if (dataSource != null) {
        return;//from w w  w . ja va2 s  .  c  o  m
    }

    if (!configFilePath.equals("")) {
        try {
            Properties dbProps = PropertiesUtils.load(configFilePath);
            ConfigurableProcessor.process(DatabaseConfig.class, dbProps);
        } catch (IOException ex) {
            log.fatal("Cannot load database config", ex);
        }
    }

    try {
        DatabaseConfig.DATABASE_DRIVER.newInstance();
    } catch (Exception e) {
        log.fatal("Error obtaining DB driver", e);
        throw new Error("DB Driver doesnt exist!");
    }

    connectionPool = new GenericObjectPool();

    if (DatabaseConfig.DATABASE_CONNECTIONS_MIN > DatabaseConfig.DATABASE_CONNECTIONS_MAX) {
        log.error("Please check your database configuration. Minimum amount of connections is > maximum");
        DatabaseConfig.DATABASE_CONNECTIONS_MAX = DatabaseConfig.DATABASE_CONNECTIONS_MIN;
    }

    connectionPool.setMaxIdle(DatabaseConfig.DATABASE_CONNECTIONS_MIN);
    connectionPool.setMaxActive(DatabaseConfig.DATABASE_CONNECTIONS_MAX);
    /* test if connection is still valid before returning */
    //connectionPool.setTestOnBorrow(true);

    try {
        dataSource = setupDataSource();
        Connection c = getConnection();
        DatabaseMetaData dmd = c.getMetaData();
        databaseName = dmd.getDatabaseProductName();
        databaseMajorVersion = dmd.getDatabaseMajorVersion();
        databaseMinorVersion = dmd.getDatabaseMinorVersion();
        c.close();
    } catch (Exception e) {
        log.fatal("Error with connection string: " + DatabaseConfig.DATABASE_URL, e);
        throw new Error("DatabaseFactory not initialized!");
    }

    log.info("Successfully connected to database");
}

From source file:com.loopj.android.http.sample.DirectorySample.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Button deleteTargetFile = new Button(this);
    deleteTargetFile.setText(R.string.button_delete_target_file);
    deleteTargetFile.setOnClickListener(new View.OnClickListener() {
        @Override/* w ww.  j  av a2 s .  c  o m*/
        public void onClick(View v) {
            clearOutputs();
            if (lastResponseHandler != null) {
                File toBeDeleted = lastResponseHandler.getTargetFile();
                debugResponse(LOG_TAG, String.format("File was deleted? %b", toBeDeleted.delete()));
                debugResponse(LOG_TAG, String.format("Delete file path: %s", toBeDeleted.getAbsolutePath()));
            } else {
                debugThrowable(LOG_TAG, new Error("You have to Run example first"));
            }
        }
    });
    cbAppend = new CheckBox(this);
    cbAppend.setText("Constructor \"append\" is true?");
    cbAppend.setChecked(false);
    cbRename = new CheckBox(this);
    cbRename.setText("Constructor \"renameTargetFileIfExists\" is true?");
    cbRename.setChecked(true);
    customFieldsLayout.addView(deleteTargetFile);
    customFieldsLayout.addView(cbAppend);
    customFieldsLayout.addView(cbRename);
}

From source file:org.mapfish.print.output.OutputFactory.java

public OutputFormat create(Config config, PJsonObject spec) {
    String id = spec.optString("outputFormat", "pdf");

    for (OutputFormatFactory formatFactory : formatFactories) {
        String enablementMsg = formatFactory.enablementStatus();
        if (enablementMsg == null) {
            for (String supportedFormat : formatFactory.formats()) {
                if (permitted(supportedFormat, config) && supportedFormat.equalsIgnoreCase(id)) {
                    final OutputFormat outputFormat = formatFactory.create(id);
                    LOGGER.info("OutputFormat chosen for " + id + " is "
                            + (outputFormat.getClass().getSimpleName()));
                    return outputFormat;
                }/*w  w  w  .  j  a v a  2  s  .co m*/
            }
        } else {
            LOGGER.warn("OutputFormatFactory " + (formatFactory.getClass().getName()) + " is disabled: "
                    + enablementMsg);
        }
    }

    if (id.equalsIgnoreCase("pdf")) {
        throw new Error("There must be a format that can output PDF");
    } else {
        StringBuilder allFormats = new StringBuilder();
        for (String format : getSupportedFormats(config)) {
            if (allFormats.length() > 0)
                allFormats.append(", ");
            allFormats.append(format.toLowerCase());
        }

        throw new IllegalArgumentException(id + " is not a supported format. Supported formats: " + allFormats);
    }
}

From source file:com.netflix.curator.framework.recipes.atomic.TestDistributedAtomicLong.java

@Test
public void testCompareAndSet() throws Exception {
    final CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
            new RetryOneTime(1));
    client.start();/*ww w .ja  v  a 2 s .c  o m*/
    try {
        final AtomicBoolean doIncrement = new AtomicBoolean(false);
        DistributedAtomicLong dal = new DistributedAtomicLong(client, "/counter", new RetryOneTime(1)) {
            @Override
            public byte[] valueToBytes(Long newValue) {
                if (doIncrement.get()) {
                    DistributedAtomicLong inc = new DistributedAtomicLong(client, "/counter",
                            new RetryOneTime(1));
                    try {
                        // this will force a bad version exception
                        inc.increment();
                    } catch (Exception e) {
                        throw new Error(e);
                    }
                }

                return super.valueToBytes(newValue);
            }
        };
        dal.forceSet(1L);

        Assert.assertTrue(dal.compareAndSet(1L, 5L).succeeded());
        Assert.assertFalse(dal.compareAndSet(1L, 5L).succeeded());

        doIncrement.set(true);
        Assert.assertFalse(dal.compareAndSet(5L, 10L).succeeded());
    } finally {
        client.close();
    }
}

From source file:edu.berkeley.compbio.ncbitaxonomy.service.NcbiTaxonomyWithUnitBranchLengthsClient.java

public NcbiTaxonomyWithUnitBranchLengthsClient() {

    ApplicationContext ctx = null;//www  . j  ava 2s .  c  o m
    try {
        ctx = NcbiTaxonomyServicesContextFactory.makeNcbiTaxonomyServicesContext();
    } catch (IOException e) {
        logger.error("Error", e);
        throw new Error(e);
    }

    ncbiTaxonomyWithUnitBranchLengthsExtractor = (NcbiTaxonomyWithUnitBranchLengthsExtractor) ctx
            .getBean("ncbiTaxonomyWithUnitBranchLengthsExtractor");
}

From source file:ca.uhn.fhir.util.UrlUtil.java

/**
 * URL encode a value/*from  ww w  . ja v a  2  s . c  o m*/
 */
public static String escape(String theValue) {
    if (theValue == null) {
        return null;
    }
    try {
        return URLEncoder.encode(theValue, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new Error("UTF-8 not supported on this platform");
    }
}