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:be.fgov.kszbcss.rhq.websphere.component.jdbc.db2.pool.ConnectionContextImpl.java

ConnectionContextImpl(Map<String, Object> properties) {
    dataSource = new DB2SimpleDataSource();
    BeanInfo beanInfo;//from   ww w .  j  a va2  s  .  c om
    try {
        beanInfo = Introspector.getBeanInfo(DB2SimpleDataSource.class);
    } catch (IntrospectionException ex) {
        throw new Error(ex);
    }
    for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
        String name = descriptor.getName();
        if (properties.containsKey(name)) {
            Object value = properties.get(name);
            Class<?> propertyType = descriptor.getPropertyType();
            if (log.isDebugEnabled()) {
                log.debug("Setting property " + name + ": propertyType=" + propertyType.getName() + ", value="
                        + value + " (class=" + (value == null ? "<N/A>" : value.getClass().getName()) + ")");
            }
            if (propertyType != String.class && value instanceof String) {
                // Need to convert value to correct type
                if (propertyType == Integer.class || propertyType == Integer.TYPE) {
                    value = Integer.valueOf((String) value);
                }
                if (log.isDebugEnabled()) {
                    log.debug("Converted value to " + value + " (class=" + value.getClass().getName() + ")");
                }
            }
            try {
                descriptor.getWriteMethod().invoke(dataSource, value);
            } catch (IllegalArgumentException ex) {
                throw new RuntimeException("Failed to set '" + name + "' property", ex);
            } catch (IllegalAccessException ex) {
                throw new IllegalAccessError(ex.getMessage());
            } catch (InvocationTargetException ex) {
                Throwable cause = ex.getCause();
                if (cause instanceof RuntimeException) {
                    throw (RuntimeException) cause;
                } else if (cause instanceof Error) {
                    throw (Error) cause;
                } else {
                    throw new RuntimeException(ex);
                }
            }
        }
    }
}

From source file:com.linecorp.armeria.server.thrift.ThriftOverHttp1Test.java

public ThriftOverHttp1Test() {
    try {//from  w ww .jav  a  2 s. c  o m
        SSLContext sslCtx = SSLContextBuilder.create()
                .loadTrustMaterial((TrustStrategy) (chain, authType) -> true).build();

        httpClient = HttpClientBuilder.create().setSSLContext(sslCtx).build();
    } catch (Exception e) {
        throw new Error(e);
    }
}

From source file:io.servicecomb.swagger.generator.springmvc.processor.annotation.RequestMappingMethodAnnotationProcessor.java

private void processMethod(RequestMethod[] requestMethods, OperationGenerator operationGenerator) {
    if (null == requestMethods || requestMethods.length == 0) {
        return;//ww  w. ja va 2  s  . c  om
    }

    if (requestMethods.length > 1) {
        throw new Error(String.format("not allowed multi http method for %s:%s",
                operationGenerator.getProviderMethod().getDeclaringClass().getName(),
                operationGenerator.getProviderMethod().getName()));
    }

    super.processMethod(requestMethods[0], operationGenerator);
}

From source file:com.fengduo.bee.commons.core.lang.BeanUtils.java

private static long getLocation(Object o) throws Exception {
    Object[] array = new Object[] { o };
    Unsafe unsafe = getUnsafe();/*from w w  w. ja  v  a2  s.com*/
    long baseOffset = unsafe.arrayBaseOffset(Object[].class);
    int addressSize = unsafe.addressSize();
    long objectAddress;
    switch (addressSize) {
    case 4:
        objectAddress = unsafe.getInt(array, baseOffset);
        break;
    case 8:
        objectAddress = unsafe.getLong(array, baseOffset);
        break;
    default:
        throw new Error("unsupported address size: " + addressSize);
    }
    return objectAddress;
}

From source file:at.molindo.webtools.crawler.CrawlerTask.java

@Override
public void run() {
    if (Thread.currentThread() instanceof CrawlerThread == false) {
        throw new Error("not a cralwer thread");
    }//  ww  w .  j av  a 2s.co m

    final CrawlerResult sr = new CrawlerResult();
    sr.setUrl(_urlString);
    sr.getReferrers().add(_referrer);

    final HttpGet get = new HttpGet(_urlString);
    // get.setFollowRedirects(false);

    try {
        final long start = System.currentTimeMillis();

        final HttpResponse response = ((CrawlerThread) Thread.currentThread()).getClient().execute(get);

        sr.setStatus(response.getStatusLine().getStatusCode());
        sr.setTime((int) (System.currentTimeMillis() - start));

        final Header[] contentTypeHeader = response.getHeaders("Content-Type");
        sr.setContentType(contentTypeHeader == null || contentTypeHeader.length == 0 ? null
                : contentTypeHeader[0].getValue());

        final String encoding = response.getEntity().getContentEncoding() == null ? null
                : response.getEntity().getContentEncoding().getValue();

        final Object content = consumeContent(response.getEntity().getContent(), sr.getContentType(),
                response.getEntity().getContentLength(), encoding);

        if (sr.getStatus() / 100 == 3) {
            String redirectLocation;
            final Header[] locationHeader = response.getHeaders("location");
            if (locationHeader != null && locationHeader.length > 0) {
                redirectLocation = locationHeader[0].getValue();
                if (redirectLocation.startsWith("/")) {
                    redirectLocation = _crawler._host + redirectLocation.substring(1);
                }
                _crawler.queue(redirectLocation, new CrawlerReferrer(_urlString,
                        response.getStatusLine().getReasonPhrase() + ": " + _referrer));
            } else {
                System.err.println("redirect without location from " + _urlString);
            }
        } else if (sr.getStatus() == HttpStatus.SC_OK) {
            if (content instanceof String) {
                sr.setText((String) content);

                if (sr.getContentType().startsWith("text/html")) {
                    parseResult(sr.getText());
                }
            }
        }
    } catch (final MalformedURLException e) {
        sr.setErrorMessage(e.getMessage());
        // e.printStackTrace();
    } catch (final IOException e) {
        sr.setErrorMessage(e.getMessage());
        e.printStackTrace();
    } catch (final SAXException e) {
        sr.setErrorMessage(e.getMessage());
        // e.printStackTrace();
    } catch (final Throwable t) {
        t.printStackTrace();
    } finally {
        _crawler.report(sr);
        // response.releaseConnection();
    }

}

From source file:edu.unc.lib.dl.cdr.sword.server.deposit.SimpleObjectDepositHandler.java

@Override
public DepositReceipt doDeposit(PID destination, Deposit deposit, PackagingType type, SwordConfiguration config,
        String depositor, String owner) throws Exception {
    log.debug("Preparing to perform a Simple Object deposit to " + destination.getPid());

    PID depositPID = null;// w  ww  . j  a  v  a2s  .c  om
    UUID depositUUID = UUID.randomUUID();
    depositPID = new PID("uuid:" + depositUUID.toString());
    File dir = makeNewDepositDirectory(depositPID.getUUID());
    dir.mkdir();

    // write deposit file to data directory
    if (deposit.getFile() != null) {
        File dataDir = new File(dir, "data");
        dataDir.mkdir();
        File depositFile = new File(dataDir, deposit.getFilename());
        try {
            FileUtils.moveFile(deposit.getFile(), depositFile);
        } catch (IOException e) {
            throw new Error(e);
        }
    }

    // Skip deposit record for this tiny ingest
    Map<String, String> options = new HashMap<String, String>();
    options.put(DepositField.excludeDepositRecord.name(), "true");

    registerDeposit(depositPID, destination, deposit, type, depositor, owner, options);
    return buildReceipt(depositPID, config);
}

From source file:it.cnr.isti.thematrix.mapping.utils.TempFileManager.java

/**
 * get a File pointing to a fresh new temporary file in the iad directory
 * @return the new temporary file/*w  ww . java  2s  . c  o m*/
 */
public static File newTempFile() {
    File tempFile;
    File dir = new File(Dynamic.getResultsPath());
    String suffix = Enums.getFileExtension(Dynamic.bufferCompression);
    try {
        tempFile = java.io.File.createTempFile("test", suffix, dir);
    } catch (IOException e) {
        throw new Error(
                "TempFileManager - Can't open temp file " + dir.toString() + " exception " + e.toString());
    }
    filenameList.add(tempFile.getAbsolutePath());
    return tempFile;
}

From source file:spark.protocol.SparqlCall.java

/** URL-encode a string as UTF-8, catching any thrown UnsupportedEncodingException. */
private static final String encode(String s) {
    try {//  w w w . j ava2  s  .  c  om
        return URLEncoder.encode(s, UTF_8);
    } catch (UnsupportedEncodingException e) {
        throw new Error("JVM unable to handle UTF-8");
    }
}

From source file:com.google.walkaround.wave.server.rpc.ChannelHandler.java

@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    try {//  ww  w  .ja va  2 s  . com
        inner(req, resp);
    } catch (JSONException e) {
        throw new Error(e);
    }
}

From source file:com.example.AbstractMongoDemo.java

protected AbstractMongoDemo initLayout() {
    try {/*from   ww w.  ja v  a  2s  . c  o  m*/

        mongoContainer = buildMongoContainer();
        table = new Table("Persons", mongoContainer);
        table.setSizeFull();
    } catch (Exception e) {
        throw new Error(e);
    }

    this.setMargin(true);

    this.addComponent(addButtons(new HorizontalLayout()));

    logger.info(mongoContainer.getContainerPropertyIds().toString());

    table.setSelectable(true);
    this.addComponent(table);
    //table.setVisibleColumns("firstName", "lastName");

    initButtons();

    return this;
}