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(String message, Throwable cause) 

Source Link

Document

Constructs a new error with the specified detail message and cause.

Usage

From source file:se.ivankrizsan.messagecowboy.EmbeddedActiveMQConfiguration.java

@Bean(initMethod = "start", destroyMethod = "stop")
public BrokerService embeddedActiveMqBroker() {
    BrokerService theActiveMqBroker = null;

    if (useEmbeddedActiveMqFlag) {
        try {// www  .  j a  va  2  s.c  o m
            theActiveMqBroker = new BrokerService();
            theActiveMqBroker.addConnector(activeMqUri);
            theActiveMqBroker.setUseJmx(activeMqJmxEnabledFlag);
            theActiveMqBroker.setPersistent(activeMqPersistenceEnabledFlag);
            theActiveMqBroker.setRestartAllowed(true);
            theActiveMqBroker.setUseShutdownHook(true);
            theActiveMqBroker.setStartAsync(false);
            theActiveMqBroker.setDestinationPolicy(activeMqDestinationPolicyMap());
        } catch (Exception theException) {
            throw new Error("Error occurred starting embedded ActiveMQ broker", theException);
        }
    }

    return theActiveMqBroker;
}

From source file:com.igormaznitsa.sciareto.preferences.FileHistoryManager.java

private FileHistoryManager() {
    final String projectsStr = PreferencesManager.getInstance().getPreferences().get(LAST_OPENED_PROJECTS,
            null);//from   w  w  w .  j  av  a  2  s.c  o m
    final String filesStr = PreferencesManager.getInstance().getPreferences().get(LAST_OPENED_FILES, null);
    try {
        final String[] folders = projectsStr == null ? new String[0]
                : decodeString(projectsStr).split("\\" + File.pathSeparatorChar);
        final String[] files = filesStr == null ? new String[0]
                : decodeString(filesStr).split("\\" + File.pathSeparatorChar);
        fillList(folders, this.lastOpenedProjects);
        fillList(files, this.lastOpenedFiles);
    } catch (Exception ex) {
        throw new Error("Can't init module", ex);
    }
}

From source file:org.nuxeo.ecm.automation.client.jaxrs.spi.auth.PortalSSOAuthInterceptor.java

@Override
public void processHttpRequest(HttpRequest request) {
    // compute token

    long ts = new Date().getTime();
    long random = new Random(ts).nextInt();

    String clearToken = String.format("%d:%d:%s:%s", ts, random, secret, username);

    byte[] hashedToken;

    try {//from   w  w w. j  av  a  2s .  c  om
        hashedToken = MessageDigest.getInstance("MD5").digest(clearToken.getBytes());
    } catch (NoSuchAlgorithmException e) {
        throw new Error("Cannot compute token", e);
    }

    String base64HashedToken = Base64.encode(hashedToken);

    // set request headers

    request.addHeader("NX_TS", String.valueOf(ts));
    request.addHeader("NX_RD", String.valueOf(random));
    request.addHeader("NX_TOKEN", base64HashedToken);
    request.addHeader("NX_USER", username);
}

From source file:edu.unc.lib.dl.xml.ModsXmlHelper.java

public static Document transform(Element mods) throws TransformerException {
    Source modsSrc = new JDOMSource(mods);
    JDOMResult dcResult = new JDOMResult();
    Transformer t = null;//www  .j  a v a 2 s  .c  o  m
    try {
        t = mods2dc.newTransformer();
    } catch (TransformerConfigurationException e) {
        throw new Error("There was a problem configuring the transformer.", e);
    }
    t.transform(modsSrc, dcResult);
    return dcResult.getDocument();
}

From source file:com.igormaznitsa.sciareto.preferences.PreferencesManager.java

private PreferencesManager() {
    this.prefs = Preferences.userNodeForPackage(PreferencesManager.class);
    String packedUuid = this.prefs.get(PROPERTY_UUID, null);
    if (packedUuid == null) {
        try {/*from   ww w  .j  a  v a 2 s . c o m*/
            final UUID newUUID = UUID.randomUUID();
            packedUuid = Base64.encodeBase64String(IOUtils.packData(newUUID.toString().getBytes("UTF-8")));
            this.prefs.put(PROPERTY_UUID, packedUuid);
            this.prefs.flush();
            LOGGER.info("Generated new installation UUID : " + newUUID.toString());

            final Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    LOGGER.info("Send first start metrics");
                    com.igormaznitsa.sciareto.metrics.MetricsService.getInstance().onFirstStart();
                }
            }, "SCIARETO_FIRST_START_METRICS");
            thread.setDaemon(true);
            thread.start();

        } catch (Exception ex) {
            LOGGER.error("Can't generate UUID", ex);
        }
    }
    try {
        this.installationUUID = UUID
                .fromString(new String(IOUtils.unpackData(Base64.decodeBase64(packedUuid)), "UTF-8"));
        LOGGER.info("Installation UUID : " + this.installationUUID.toString());
    } catch (UnsupportedEncodingException ex) {
        LOGGER.error("Can't decode UUID", ex);
        throw new Error("Unexpected error", ex);
    }
}

From source file:com.amazonaws.services.simpleworkflow.flow.common.WorkflowExecutionUtils.java

/**
 * Blocks until workflow instance completes and returns its result. Useful
 * for unit tests and during development. <strong>Never</strong> use in
 * production setting as polling for worklow instance status is an expensive
 * operation./* w  w w  .  j ava  2s  . com*/
 * 
 * @param workflowExecution
 *            result of
 *            {@link AmazonSimpleWorkflow#startWorkflowInstance(com.amazonaws.services.simpleworkflow.model.StartWorkflowInstanceRequest)}
 * @return workflow instance result.
 * @throws InterruptedException
 *             if thread is interrupted
 * @throws RuntimeException
 *             if workflow instance ended up in any state but completed
 */
public static WorkflowExecutionCompletedEventAttributes waitForWorkflowExecutionResult(
        AmazonSimpleWorkflow service, String domain, WorkflowExecution workflowExecution)
        throws InterruptedException {
    try {
        return waitForWorkflowExecutionResult(service, domain, workflowExecution, 0);
    } catch (TimeoutException e) {
        throw new Error("should never happen", e);
    }
}

From source file:org.brutusin.json.impl.JacksonSchemaFactory.java

void enrich(SimpleTypeSchema schema, BeanProperty beanProperty) {
    JsonProperty jsonAnnot = beanProperty.getAnnotation(JsonProperty.class);
    IndexableProperty indexAnnot = beanProperty.getAnnotation(IndexableProperty.class);
    DependentProperty dependsAnnot = beanProperty.getAnnotation(DependentProperty.class);

    if (schema instanceof StringSchema) {
        StringSchema sschema = (StringSchema) schema;
        try {//from  w  w  w  .jav a  2  s.  co  m
            Set<String> enums = sschema.getEnums();
            if (enums != null) {
                Method method = schema.getClass().getMethod("setValues", List.class);
                method.invoke(schema, new ArrayList(enums));
            }
        } catch (Exception parseException) {
            throw new Error("Error setting enum value from enumeration for " + beanProperty.getFullName(),
                    parseException);
        }
    }

    if (jsonAnnot == null) {
        schema.setTitle(beanProperty.getName());
    } else {
        if (jsonAnnot.title() != null) {
            schema.setTitle(jsonAnnot.title());
        } else {
            schema.setTitle(beanProperty.getName());
        }
        schema.setDescription(jsonAnnot.description());
        schema.setRequired(jsonAnnot.required());
        String def = jsonAnnot.defaultJsonExp();
        if (def != null) {
            try {
                Object defaultValue = JsonCodec.getInstance().parse(def, beanProperty.getType().getRawClass());
                Method method = schema.getClass().getMethod("setDef", Object.class);
                method.invoke(schema, defaultValue);
            } catch (Exception parseException) {
                throw new Error("Error setting default value for " + beanProperty.getFullName(),
                        parseException);
            }
        }
        String valuesMethodName = jsonAnnot.valuesMethod();
        if (valuesMethodName != null && !valuesMethodName.isEmpty()) {
            try {
                Method valuesMethod = beanProperty.getMember().getDeclaringClass().getMethod(valuesMethodName,
                        null);
                valuesMethod.setAccessible(true);
                Object valuesValue = valuesMethod.invoke(null, null);
                Method method = schema.getClass().getMethod("setValues", List.class);
                method.invoke(schema, valuesValue);
            } catch (Exception ex) {
                throw new Error("Error setting enum value from @JsonProperty.valuesMethod() for "
                        + beanProperty.getFullName(), ex);
            }
        } else {
            String values = jsonAnnot.values();
            if (values != null && !values.isEmpty()) {
                try {
                    Object valuesValue = JsonCodec.getInstance().parse(values, List.class);
                    Method method = schema.getClass().getMethod("setValues", List.class);
                    method.invoke(schema, valuesValue);
                } catch (Exception parseException) {
                    throw new Error("Error setting enum value from @JsonProperty.values() for "
                            + beanProperty.getFullName(), parseException);
                }
            }
        }
    }
    if (indexAnnot != null) {
        try {
            Method method = schema.getClass().getMethod("setIndex", IndexableProperty.IndexMode.class);
            method.invoke(schema, indexAnnot.mode());
        } catch (Exception parseException) {
            throw new Error("Error setting index value for " + beanProperty.getFullName(), parseException);
        }
    }
    if (dependsAnnot != null) {
        try {
            Method method = schema.getClass().getMethod("setDependsOn", String[].class);
            method.invoke(schema, (Object) dependsAnnot.dependsOn());
        } catch (Exception parseException) {
            throw new Error("Error setting dependsOn value for " + beanProperty.getFullName(), parseException);
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamSaxLoader.CFBamSaxLoaderClusterHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from w  w  w  .  jav  a2s . co m*/
        final String S_ProcName = "startElement";
        assert qName.equals("Cluster");

        CFBamSaxLoader saxLoader = (CFBamSaxLoader) getParser();
        if (saxLoader == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFBamSchemaObj schemaObj = saxLoader.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        CFLibXmlCoreContext curContext = getParser().getCurContext();

        ICFSecurityClusterObj useCluster = saxLoader.getUseCluster();
        if (useCluster == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "saxLoader.useCluster");
        }

        curContext.putNamedValue("Object", useCluster);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_9.CFBamSaxLoader.CFBamSaxLoaderTenantHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*  w w  w .j a v  a2s. c  om*/
        final String S_ProcName = "startElement";
        assert qName.equals("Tenant");

        CFBamSaxLoader saxLoader = (CFBamSaxLoader) getParser();
        if (saxLoader == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFBamSchemaObj schemaObj = saxLoader.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        CFLibXmlCoreContext curContext = getParser().getCurContext();

        ICFSecurityTenantObj useTenant = saxLoader.getUseTenant();
        if (useTenant == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "saxLoader.useTenant");
        }

        curContext.putNamedValue("Object", useTenant);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSaxLoader.CFAsteriskSaxLoaderTenantHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from   w w w. java2  s  .  c o m
        final String S_ProcName = "startElement";
        assert qName.equals("Tenant");

        CFAsteriskSaxLoader saxLoader = (CFAsteriskSaxLoader) getParser();
        if (saxLoader == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAsteriskSchemaObj schemaObj = saxLoader.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        CFLibXmlCoreContext curContext = getParser().getCurContext();

        ICFSecurityTenantObj useTenant = saxLoader.getUseTenant();
        if (useTenant == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "saxLoader.useTenant");
        }

        curContext.putNamedValue("Object", useTenant);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}