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:hudson.model.UsageStatistics.java

private Cipher getCipher() {
    try {/*from  w w w.j ava2 s.com*/
        if (key == null) {
            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            key = keyFactory.generatePublic(new X509EncodedKeySpec(Util.fromHexString(keyImage)));
        }

        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.ENCRYPT_MODE, key);
        return cipher;
    } catch (GeneralSecurityException e) {
        throw new Error(e); // impossible
    }
}

From source file:org.doctester.testbrowser.TestBrowserImpl.java

@Override
public Response makeRequest(Request httpRequest) {

    Response httpResponse;//  w  w w  .  ja  va2s  .com

    if (Sets.newHashSet(HEAD, GET, DELETE).contains(httpRequest.httpRequestType)) {

        httpResponse = makeHeadGetOrDeleteRequest(httpRequest);

    } else if (Sets.newHashSet(POST, PUT).contains(httpRequest.httpRequestType)) {

        httpResponse = makePostOrPutRequest(httpRequest);

    } else {

        throw new RuntimeErrorException(
                new Error("Your requested httpRequest.httpRequestType is not supported"));
    }

    return httpResponse;

}

From source file:com.igormaznitsa.jute.Utils.java

public static String toStandardJavaClassName(final String rootPath, final String classFilePath) {
    if (rootPath.length() >= classFilePath.length()) {
        throw new Error("Unexpected situation #112321223 (" + rootPath + " >= " + classFilePath + ')');
    }/*from  w  w  w  .j  ava 2 s .c om*/
    String diff = classFilePath.substring(rootPath.length()).replace('\\', '.').replace('/', '.');
    if (diff.toLowerCase(Locale.ENGLISH).endsWith(".class")) {
        diff = diff.substring(0, diff.length() - ".class".length());
    }
    return diff;
}

From source file:hudson.remoting.DummyClassLoader.java

/**
 * Loads a class that looks like an exact clone of the named class under
 * a different class name.//from w w w  . ja  v a2  s. c om
 */
public Object load(Class c) {
    for (Entry e : entries) {
        if (e.c == c) {
            try {
                return loadClass(e.logicalName).newInstance();
            } catch (InstantiationException x) {
                throw new Error(x);
            } catch (IllegalAccessException x) {
                throw new Error(x);
            } catch (ClassNotFoundException x) {
                throw new Error(x);
            }
        }
    }
    throw new IllegalStateException();
}

From source file:net.kourlas.voipms_sms.preferences.DidPreference.java

@Override
protected void onClick() {
    progressDialog = new ProgressDialog(getContext());
    progressDialog.setMessage(//from   www .  j a v a 2 s. co  m
            getContext().getApplicationContext().getString(R.string.preferences_account_did_status));
    progressDialog.setCancelable(false);
    progressDialog.show();

    SelectDidTask task = new SelectDidTask(this);

    if (preferences.getEmail().equals("")) {
        task.cleanup(false, null, applicationContext.getString(R.string.preferences_account_did_error_email));
        return;
    }

    if (preferences.getPassword().equals("")) {
        task.cleanup(false, null,
                applicationContext.getString(R.string.preferences_account_did_error_password));
        return;
    }

    if (!Utils.isNetworkConnectionAvailable(applicationContext)) {
        task.cleanup(false, null, applicationContext.getString(R.string.preferences_account_did_error_network));
        return;
    }

    try {
        String voipUrl = "https://www.voip.ms/api/v1/rest.php?" + "api_username="
                + URLEncoder.encode(preferences.getEmail(), "UTF-8") + "&" + "api_password="
                + URLEncoder.encode(preferences.getPassword(), "UTF-8") + "&" + "method=getDIDsInfo";
        task.start(voipUrl);
    } catch (UnsupportedEncodingException ex) {
        // This should never happen since the encoding (UTF-8) is hardcoded
        throw new Error(ex);
    }
}

From source file:nl.esciencecenter.ptk.csv.CSVData.java

public void setField(int rowNr, int fieldNr, String fieldValue) {
    String row[] = data.get(rowNr);
    if (row == null)
        throw new Error("No such row:" + rowNr);

    row[fieldNr] = fieldValue;/*from   w w w. ja v  a 2s.c  o m*/
}

From source file:net.sf.jabref.exporter.OpenOfficeDocumentCreator.java

private static void exportOpenOfficeCalcXML(File tmpFile, BibDatabase database, List<BibEntry> entries) {
    OOCalcDatabase od = new OOCalcDatabase(database, entries);

    try (Writer ps = new OutputStreamWriter(new FileOutputStream(tmpFile), StandardCharsets.UTF_8)) {
        DOMSource source = new DOMSource(od.getDOMrepresentation());
        StreamResult result = new StreamResult(ps);
        Transformer trans = TransformerFactory.newInstance().newTransformer();
        trans.setOutputProperty(OutputKeys.INDENT, "yes");
        trans.transform(source, result);
    } catch (Exception e) {
        throw new Error(e);
    }//from w w  w  .ja v a2 s.c om

}

From source file:org.tsho.dmc2.managers.BifurcationManager.java

public boolean doRendering(final boolean redraw) {

    switch (form.getType()) {
    case BifurcationControlForm2.TYPE_SINGLE:
        return renderSingle(redraw);

    case BifurcationControlForm2.TYPE_DOUBLE:
        return renderDouble(redraw);

    default:// www.ja va2s. c o m
        throw new Error("invalid type");
    }
}

From source file:com.genentech.struchk.NormalizerPool.java

/**
 * Check a molfile.//w w  w  .  jav  a2s . c  o  m
 */
public GNEMolecule normalizeOEMol(OEGraphMol mol, String gneStructFlag) {
    PooledNormalizer pnorm = null;
    try {
        pnorm = (PooledNormalizer) pool.borrowObject();
        return pnorm.norm.normalizeOEMol(mol, gneStructFlag);
    } catch (Exception e) {
        handleException(pnorm, e);
        throw new Error(e);
    } finally {
        returnToPool(pnorm);
    }
}

From source file:marytts.server.MaryProperties.java

/**
 * From a path entry in the properties, create an expanded form.
 * Replace the string MARY_BASE with the value of property "mary.base";
 * replace all "/" and "\\" with the platform-specific file separator.
 *//*from   w ww  . j a va 2 s. com*/
private static String expandPath(String path) {
    final String MARY_BASE = "MARY_BASE";
    StringBuilder buf = null;
    if (path.startsWith(MARY_BASE)) {
        buf = new StringBuilder(maryBase());
        buf.append(path.substring(MARY_BASE.length()));
    } else {
        buf = new StringBuilder(path);
    }
    if (File.separator.equals("/")) {
        int i = -1;
        while ((i = buf.indexOf("\\")) != -1)
            buf.replace(i, i + 1, "/");
    } else if (File.separator.equals("\\")) {
        int i = -1;
        while ((i = buf.indexOf("/")) != -1)
            buf.replace(i, i + 1, "\\");
    } else {
        throw new Error("Unexpected File.separator: `" + File.separator + "'");
    }
    return buf.toString();
}