Example usage for java.lang Error getMessage

List of usage examples for java.lang Error getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.samsung.trailmix.multiscreen.MultiscreenManager.java

/**
 * Connect to given service./* w  w  w.  ja  v a  2  s.co  m*/
 *
 * @param service the service to be connected. disconnect current service if it is null.
 */
public void connectToService(final Service service) {
    if (service == null) {
        disconnect();
        return;
    }

    if (this.service != null) {

        // Launch the TV App directly if we already got the TV service.
        if (this.service.equals(service)) {

            // Launch the TV app if it is not connected, otherwise do nothing.
            if (!multiscreenApp.isConnected()) {
                launchApplication();
            }

        } else {

            // If different TV is selected, disconnect the previous application.
            if (multiscreenApp != null && multiscreenApp.isConnected()) {
                multiscreenApp.disconnect(true, new Result<Client>() {
                    @Override
                    public void onSuccess(Client client) {
                        // disconnect onSuccess, update service.
                        updateServiceAndConnect(service);
                    }

                    @Override
                    public void onError(com.samsung.multiscreen.Error error) {
                        // disconnect failed.
                        Util.e("disconnect onError: " + error.getMessage());

                        // Update service.
                        updateServiceAndConnect(service);
                    }
                });
            } else {
                updateServiceAndConnect(service);
            }
        }
    } else {
        //connect to a new TV.
        updateServiceAndConnect(service);
    }
}

From source file:com.samsung.soundscape.util.ConnectivityManager.java

/**
 * Set the TV service.//from   w w w. j  a  v  a2  s .  co m
 *
 * @param service the new TV service to be used.
 */
public void setService(final Service service) {
    if (this.service != null) {

        //Launch the TV mMultiscreenApp directly if we already got the TV service.
        if (this.service.equals(service)) {

            //Launch the TV app it is not connected.
            //Do nothing if it is already connected.
            if (!mMultiscreenApp.isConnected()) {
                launchApplication();
            }

        } else {

            //If different TV is selected, disconnect the previous application.
            if (mMultiscreenApp != null && mMultiscreenApp.isConnected()) {
                mMultiscreenApp.disconnect(true, new Result<Client>() {
                    @Override
                    public void onSuccess(Client client) {
                        //disconnect onSuccess, update service.
                        updateServiceAndConnect(service);
                    }

                    @Override
                    public void onError(com.samsung.multiscreen.Error error) {
                        //disconnect failed.
                        Util.e("disconnect onError: " + error.getMessage());

                        //Update service.
                        updateServiceAndConnect(service);
                    }
                });
            } else {
                updateServiceAndConnect(service);
            }
        }
    } else {
        //connect to a new TV.
        updateServiceAndConnect(service);
    }
}

From source file:com.samsung.trailmix.multiscreen.MultiscreenManager.java

/**
 * Makes connection to the TV and start the application on the TV
 * if the current service is available.//from   w  w w  .  ja  v  a 2  s .co m
 */
public void launchApplication() {
    if (service == null) {
        return;
    }

    // Parse Application Url.
    Uri url = Uri.parse(APP_URL);

    // Get an instance of Application.
    multiscreenApp = service.createApplication(url, CHANNEL_ID);

    // Set the connection timeout to 20 seconds.
    // When the TV is unavailable after 20 seconds, onDisconnect event is called.
    multiscreenApp.setConnectionTimeout(20000);

    // Listen for the disconnect event.
    multiscreenApp.setOnDisconnectListener(new Channel.OnDisconnectListener() {
        @Override
        public void onDisconnect(Client client) {
            if (client != null) {

                // Notify service change listeners.
                EventBus.getDefault().post(new ConnectionChangedEvent(null));
            }
        }
    });

    // Listen for the connect event
    multiscreenApp.setOnConnectListener(new Channel.OnConnectListener() {
        @Override
        public void onConnect(Client client) {

            // Notify to update UI.
            EventBus.getDefault().post(new ConnectionChangedEvent(null));
        }
    });

    // Listen for the errors.
    multiscreenApp.setOnErrorListener(new Channel.OnErrorListener() {
        @Override
        public void onError(com.samsung.multiscreen.Error error) {
            Util.e("setOnErrorListener: " + error.toString());
            EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage()));
        }
    });

    // Add message listeners.
    multiscreenApp.addOnMessageListener(EVENT_APP_STATE, onAppStateListener);
    multiscreenApp.addOnMessageListener(EVENT_VIDEO_STATUS, onVideoStatusListener);
    multiscreenApp.addOnMessageListener(EVENT_VIDEO_START, onVideoStartListener);
    multiscreenApp.addOnMessageListener(EVENT_VIDEO_END, onVideoEndListener);

    // Connect and launch the TV application.
    // The timeout is 30 seconds.
    multiscreenApp.connect(null, 30000, new Result<Client>() {

        @Override
        public void onSuccess(Client client) {
        }

        @Override
        public void onError(com.samsung.multiscreen.Error error) {
            Util.e("connect onError: " + error.toString());

            // failed to launch TV application. Notify TV service changes.
            EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage()));
        }
    });
}

From source file:com.fujitsu.dc.engine.DcEngineContext.java

/**
 * JSGI./*from w  ww . ja  v a2  s.  c  o  m*/
 * @param source ?
 * @param req Request
 * @param res Response
 * @param is 
 * @param serviceSubject 
 * @return Response
 * @throws DcEngineException DcEngine
 */
public final Response runJsgi(final String source, final HttpServletRequest req, final HttpServletResponse res,
        final InputStream is, final String serviceSubject) throws DcEngineException {
    // JSGI
    // DAO?
    DcEngineDao dc = createDao(req, serviceSubject);

    // DAOJavaScript?
    javaToJs(dc, "dcjvm");

    // RequireJavaScript?
    javaToJs(createRequireObject(), "dcrequire");

    // dc-dao.js ??
    try {
        loadJs("dc-dao");
    } catch (IOException e1) {
        log.info("runJsgi error (DAO load io error) ", e1);
        throw new DcEngineException("Server Error", DcEngineException.STATUSCODE_SERVER_ERROR, e1);
    }

    // dc-lib.js ??
    try {
        loadJs("dc-lib");
    } catch (IOException e1) {
        log.info("runJsgi error (dc-lib load io error) ", e1);
        throw new DcEngineException("Server Error", DcEngineException.STATUSCODE_SERVER_ERROR, e1);
    }

    // jsgi-lib.js??
    try {
        loadJs("jsgi-lib");
    } catch (IOException e1) {
        log.info("runJsgi error (jsgi-lib load io error) ", e1);
        throw new DcEngineException("Server Error", DcEngineException.STATUSCODE_SERVER_ERROR, e1);
    }

    // dc?????Extension??
    prepareExtensionClass();

    // RequestJavaScript?
    JSGIRequest dcReq = new JSGIRequest(req, new DcRequestBodyStream(is));

    // JSGI
    // (eval)?
    try {
        Object ret;
        log.info("eval user script : script size = " + source.length());
        ret = evalUserScript(source, dcReq);
        log.info("[" + DcEngineConfig.getVersion() + "] " + "<<< Request Ended ");

        DcResponse dcRes = DcResponse.parseJsgiResponse(ret);

        return dcRes.build();
    } catch (Error e) {
        // ??INFO?
        log.info("UserScript TimeOut", e);
        throw new DcEngineException("Script TimeOut", HttpStatus.SC_SERVICE_UNAVAILABLE);
    } catch (Exception e) {
        if (e instanceof WrappedException) {
            e = (Exception) ((WrappedException) e).getWrappedException();
        }

        // ???INFO?
        log.info("User Script Evalucation Error : " + e.getMessage(), e);
        throw new DcEngineException("Server Error : " + e.getMessage(),
                DcEngineException.STATUSCODE_SERVER_ERROR, e);
    }
}

From source file:javancss.Javancss.java

private void _measureSource(Reader reader) throws Exception, Error {
    log.fine("_measureSource(Reader).ENTER");

    try {/*from  w  ww  .  j  a  va  2  s .co m*/
        // create a parser object
        if (log.isLoggable(Level.FINE)) {
            log.fine("creating JavaParserDebug");
            _pJavaParser = new JavaParserDebug(reader);
        } else {
            log.fine("creating JavaParser");
            _pJavaParser = new JavaParser(reader);
        }

        // execute the parser
        _pJavaParser.parse();
        log.fine("Javancss._measureSource(DataInputStream).SUCCESSFULLY_PARSED");

        _ncss += _pJavaParser.getNcss(); // increment the ncss
        _loc += _pJavaParser.getLOC(); // and loc
        // add new data to global vector
        _vFunctionMetrics.addAll(_pJavaParser.getFunction());
        _vObjectMetrics.addAll(_pJavaParser.getObject());
        Map<String, PackageMetric> htNewPackages = _pJavaParser.getPackage();

        /* List vNewPackages = new Vector(); */
        for (Map.Entry<String, PackageMetric> entry : htNewPackages.entrySet()) {
            String sPackage = entry.getKey();

            PackageMetric pckmNext = htNewPackages.get(sPackage);
            pckmNext.name = sPackage;

            PackageMetric pckmPrevious = _htPackages.get(sPackage);
            pckmNext.add(pckmPrevious);

            _htPackages.put(sPackage, pckmNext);
        }
    } catch (Exception pParseException) {
        if (_sErrorMessage == null) {
            _sErrorMessage = "";
        }
        _sErrorMessage += "ParseException in STDIN";
        if (_pJavaParser != null) {
            _sErrorMessage += "\nLast useful checkpoint: \"" + _pJavaParser.getLastFunction() + "\"\n";
        }
        _sErrorMessage += pParseException.getMessage() + "\n";
        _thrwError = pParseException;

        throw pParseException;
    } catch (Error pTokenMgrError) {
        if (_sErrorMessage == null) {
            _sErrorMessage = "";
        }
        _sErrorMessage += "TokenMgrError in STDIN\n";
        _sErrorMessage += pTokenMgrError.getMessage() + "\n";
        _thrwError = pTokenMgrError;

        throw pTokenMgrError;
    }
}

From source file:io.personium.engine.PersoniumEngineContext.java

/**
 * JSGI.//from   w  ww. j  a  va 2  s.co  m
 * @param source ?
 * @param req Request
 * @param res Response
 * @param is 
 * @param serviceSubject 
 * @return Response
 * @throws PersoniumEngineException PersoniumEngine
 */
public final Response runJsgi(final String source, final HttpServletRequest req, final HttpServletResponse res,
        final InputStream is, final String serviceSubject) throws PersoniumEngineException {
    // JSGI
    // DAO?
    PersoniumEngineDao ed = createDao(req, serviceSubject);

    // DAOJavaScript?
    javaToJs(ed, "pjvm");

    // RequireJavaScript?
    javaToJs(createRequireObject(), "_require");

    // personium-dao.js ??
    try {
        loadJs("personium-dao");
    } catch (IOException e1) {
        log.info("runJsgi error (DAO load io error) ", e1);
        throw new PersoniumEngineException("Server Error", PersoniumEngineException.STATUSCODE_SERVER_ERROR,
                e1);
    }

    // personium-lib.js ??
    try {
        loadJs("personium-lib");
    } catch (IOException e1) {
        log.info("runJsgi error (personium-lib load io error) ", e1);
        throw new PersoniumEngineException("Server Error", PersoniumEngineException.STATUSCODE_SERVER_ERROR,
                e1);
    }

    // jsgi-lib.js??
    try {
        loadJs("jsgi-lib");
    } catch (IOException e1) {
        log.info("runJsgi error (jsgi-lib load io error) ", e1);
        throw new PersoniumEngineException("Server Error", PersoniumEngineException.STATUSCODE_SERVER_ERROR,
                e1);
    }

    // p?????Extension??
    prepareExtensionClass();

    // RequestJavaScript?
    JSGIRequest jsReq = new JSGIRequest(req, new PersoniumRequestBodyStream(is));

    // JSGI
    // (eval)?
    try {
        Object ret;
        log.info("eval user script : script size = " + source.length());
        ret = evalUserScript(source, jsReq);
        log.info("[" + PersoniumEngineConfig.getVersion() + "] " + "<<< Request Ended ");

        PersoniumResponse pRes = PersoniumResponse.parseJsgiResponse(ret);

        return pRes.build();
    } catch (Error e) {
        // ??INFO?
        log.info("UserScript TimeOut", e);
        throw new PersoniumEngineException("Script TimeOut", HttpStatus.SC_SERVICE_UNAVAILABLE);
    } catch (Exception e) {
        if (e instanceof WrappedException) {
            e = (Exception) ((WrappedException) e).getWrappedException();
        }

        // ???INFO?
        log.info("User Script Evalucation Error : " + e.getMessage(), e);
        throw new PersoniumEngineException("Server Error : " + e.getMessage(),
                PersoniumEngineException.STATUSCODE_SERVER_ERROR, e);
    }
}

From source file:javancss.Javancss.java

private void _measureSource(File sSourceFile_) throws Exception, Error {
    Reader reader;//from  w w  w  . j a v  a  2s.c  om

    // opens the file
    try {
        reader = newReader(sSourceFile_);
    } catch (IOException pIOException) {
        if (_sErrorMessage == null || _sErrorMessage.trim().length() == 0) {
            _sErrorMessage = "";
        } else {
            _sErrorMessage += "\n";
        }
        _sErrorMessage += "File not found: " + sSourceFile_.getAbsolutePath();
        _thrwError = pIOException;

        throw pIOException;
    }

    String sTempErrorMessage = _sErrorMessage;
    try {
        // the same method but with a Reader
        _measureSource(reader);
    } catch (Exception pParseException) {
        if (sTempErrorMessage == null) {
            sTempErrorMessage = "";
        }
        sTempErrorMessage += "ParseException in " + sSourceFile_.getAbsolutePath()
                + "\nLast useful checkpoint: \"" + _pJavaParser.getLastFunction() + "\"\n";
        sTempErrorMessage += pParseException.getMessage() + "\n";

        _sErrorMessage = sTempErrorMessage;
        _thrwError = pParseException;

        throw pParseException;
    } catch (Error pTokenMgrError) {
        if (sTempErrorMessage == null) {
            sTempErrorMessage = "";
        }
        sTempErrorMessage += "TokenMgrError in " + sSourceFile_.getAbsolutePath() + "\n"
                + pTokenMgrError.getMessage() + "\n";
        _sErrorMessage = sTempErrorMessage;
        _thrwError = pTokenMgrError;

        throw pTokenMgrError;
    }
}

From source file:com.samsung.soundscape.util.ConnectivityManager.java

/**
 * Makes connection to the TV and start the application on the TV
 * if the current service is available./*w  w w .jav a  2 s  .  c om*/
 */
public void launchApplication() {
    if (service == null) {
        return;
    }

    //Parse Application Url.
    Uri url = Uri.parse(App.getInstance().getString(R.string.app_url));

    // Get an instance of Application.
    mMultiscreenApp = service.createApplication(url, App.getInstance().getString(R.string.channel_id));

    //Set the connection timeout to 20 seconds.
    //When the TV is unavailable after 20 seconds, onDisconnect event is called.
    mMultiscreenApp.setConnectionTimeout(20000);

    //Listen for the disconnect event.
    mMultiscreenApp.setOnDisconnectListener(new Channel.OnDisconnectListener() {
        @Override
        public void onDisconnect(Client client) {
            if (client != null) {

                //Notify service change listeners.
                EventBus.getDefault().post(new ConnectionChangedEvent(null));

                //restart to discovery if service is disconnected and
                // this application is not closing.
                if (!isExisting)
                    startDiscovery();
            }
        }
    });

    // Listen for the connect event
    mMultiscreenApp.setOnConnectListener(new Channel.OnConnectListener() {
        @Override
        public void onConnect(Client client) {
            //stop discovery to save battery when a service is selected.
            stopDiscovery();

            //Notify to update UI.
            EventBus.getDefault().post(new ConnectionChangedEvent(null));
        }
    });

    // Listen for the errors.
    mMultiscreenApp.setOnErrorListener(new Channel.OnErrorListener() {
        @Override
        public void onError(com.samsung.multiscreen.Error error) {
            Util.e("setOnErrorListener: " + error.toString());
            EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage()));

            if (!isExisting)
                startDiscovery();
        }
    });

    mMultiscreenApp.addOnMessageListener(EVENT_APP_STATE, onAppStateListener);
    mMultiscreenApp.addOnMessageListener(EVENT_TRACK_STATUS, onTrackStatusListener);
    mMultiscreenApp.addOnMessageListener(EVENT_ADD_TRACK, onAddTrackListener);
    mMultiscreenApp.addOnMessageListener(EVENT_TRACK_START, onTrackStartListener);
    mMultiscreenApp.addOnMessageListener(EVENT_TRACK_END, onTrackEndListener);
    mMultiscreenApp.addOnMessageListener(EVENT_ASSIGN_COLOR, onAssignColorListener);
    mMultiscreenApp.addOnMessageListener(EVENT_REMOVE_TRACK, onRemoveTrackColorListener);

    //Connect and launch the TV application.
    mMultiscreenApp.connect(null, 30000, new Result<Client>() {

        @Override
        public void onSuccess(Client client) {
        }

        @Override
        public void onError(com.samsung.multiscreen.Error error) {
            Util.e("connect onError: " + error.toString());

            //failed to launch TV application. Notify TV service changes.
            EventBus.getDefault().post(new ConnectionChangedEvent(error.getMessage()));
        }
    });
}

From source file:javancss.Javancss.java

public boolean parseImports() {
    if (_sJavaSourceFile == null) {
        log.fine("Javancss.parseImports().NO_FILE");

        return true;
    }/*from w  w  w  .  j ava 2 s.  c  o m*/
    Reader reader = createSourceReader(_sJavaSourceFile);
    if (reader == null) {
        log.fine("Javancss.parseImports().NO_DIS");

        return true;
    }

    try {
        log.fine("Javancss.parseImports().START_PARSING");
        if (!log.isLoggable(Level.FINE)) {
            _pJavaParser = new JavaParser(reader);
        } else {
            _pJavaParser = new JavaParserDebug(reader);
        }
        _pJavaParser.parseImportUnit();
        _vImports = _pJavaParser.getImports();
        _aoPackage = _pJavaParser.getPackageObjects();
        log.fine("Javancss.parseImports().END_PARSING");
    } catch (Exception pParseException) {
        log.fine("Javancss.parseImports().PARSE_EXCEPTION");
        if (_sErrorMessage == null) {
            _sErrorMessage = "";
        }
        _sErrorMessage += "ParseException in STDIN";
        if (_pJavaParser != null) {
            _sErrorMessage += "\nLast useful checkpoint: \"" + _pJavaParser.getLastFunction() + "\"\n";
        }
        _sErrorMessage += pParseException.getMessage() + "\n";
        _thrwError = pParseException;

        return true;
    } catch (Error pTokenMgrError) {
        log.fine("Javancss.parseImports().TOKEN_ERROR");
        if (_sErrorMessage == null) {
            _sErrorMessage = "";
        }
        _sErrorMessage += "TokenMgrError in STDIN\n";
        _sErrorMessage += pTokenMgrError.getMessage() + "\n";
        _thrwError = pTokenMgrError;

        return true;
    }

    return false;
}

From source file:org.wso2.carbon.sequences.services.SequenceAdmin.java

/**
 * Add a sequence into the synapseConfiguration
 *
 * @param sequenceElement - Sequence object to be added as an OMElement
 * @throws SequenceEditorException if a sequence exists with the same name or if the
 *                   element provided is not a Sequence element
 *///from  www . ja v  a2 s.  c  o m
public void addSequence(OMElement sequenceElement) throws SequenceEditorException {
    final Lock lock = getLock();
    try {
        lock.lock();
        if (sequenceElement.getLocalName().equals(XMLConfigConstants.SEQUENCE_ELT.getLocalPart())) {
            String sequenceName = sequenceElement.getAttributeValue(new QName("name"));
            if ("".equals(sequenceName) || null == sequenceName) {
                handleException("sequence name is required.");
            }
            SynapseConfiguration config = getSynapseConfiguration();
            if (log.isDebugEnabled()) {
                log.debug("Adding sequence : " + sequenceName + " to the configuration");
            }
            if (config.getLocalRegistry().get(sequenceName) != null) {
                handleException("The name '" + sequenceName
                        + "' is already used within the configuration - a sequence or local entry with this name already exists");
            } else {
                SynapseXMLConfigurationFactory.defineSequence(config, sequenceElement,
                        getSynapseConfiguration().getProperties());
                if (log.isDebugEnabled()) {
                    log.debug("Added sequence : " + sequenceName + " to the configuration");
                }

                SequenceMediator seq = config.getDefinedSequences().get(sequenceName);
                seq.setFileName(ServiceBusUtils.generateFileName(sequenceName));
                seq.init(getSynapseEnvironment());

                //noinspection ConstantConditions
                persistSequence(seq);
            }
        } else {
            handleException("Invalid sequence definition");
        }
    } catch (Exception fault) {
        throw new SequenceEditorException("Error adding sequence : " + fault.getMessage(), fault);
    } catch (Error error) {
        throw new SequenceEditorException(
                "Unexpected error occured while " + "adding the sequence : " + error.getMessage(), error);
    } finally {
        lock.unlock();
    }
}