Example usage for java.lang RuntimeException getLocalizedMessage

List of usage examples for java.lang RuntimeException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:net.agkn.field_stripe.FileRecordEncoder.java

/**
 * Parse all Protobuf (*.proto) files in the specified path.
 *///from  ww w .j  a  v a2s  .co m
public static List<Proto> parseProtobufDefinitions(final File protobufPath) {
    final List<Proto> protobufDefinitions = new ArrayList<Proto>();
    final Iterator<File> protobufFiles = FileUtils.iterateFiles(protobufPath, new String[] { "proto" },
            true/*recursively*/);
    while (protobufFiles.hasNext()) {
        final File protobufFile = protobufFiles.next();
        if (protobufFile.isDirectory())
            continue/*ignore directories*/;

        // CHECK:  should this continue if there's an error parsing?
        try {
            protobufDefinitions.add(ProtoUtil.parseProto(protobufFile));
        } catch (final RuntimeException re) {
            System.err.println("An error occurred while parsing: " + protobufFile.getAbsolutePath());
            System.err.println(re.getLocalizedMessage());
        }
    }
    return protobufDefinitions;
}

From source file:org.kalypso.model.wspm.ui.view.chart.AbstractProfilePointsLayer.java

public static String formatTooltip(final IProfileRecord point, final String domainComponentID,
        final String targetComponentID, final String... additionsComponentIDs) {
    final IProfile profile = point.getProfile();

    final IComponent domainComponent = profile.hasPointProperty(domainComponentID);
    final IComponent targetComponent = profile.hasPointProperty(targetComponentID);
    if (Objects.isNull(point, targetComponent, domainComponent))
        return StringUtils.EMPTY;

    try {//from   w ww .  java2 s  .  c o  m
        final TooltipFormatter formatter = new TooltipFormatter(null, new String[] { "%s", "%s", "%s" }, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                new int[] { SWT.LEFT, SWT.RIGHT, SWT.LEFT });

        final String domainUnit = ComponentUtilities.getComponentUnitLabel(domainComponent);
        final Object domainValue = point.getValue(domainComponent);
        formatter.addLine(domainComponent.getName(), String.format("%10.2f", domainValue), domainUnit); //$NON-NLS-1$

        final String targetUnit = ComponentUtilities.getComponentUnitLabel(targetComponent);
        final Object targetValue = point.getValue(targetComponent);
        formatter.addLine(targetComponent.getName(), String.format("%10.2f", targetValue), targetUnit); //$NON-NLS-1$

        /* code if set */
        for (final String additionalComponentID : additionsComponentIDs) {
            final IComponent additionalComponent = profile.hasPointProperty(additionalComponentID);
            if (additionalComponent != null) {
                final Object additionalValue = point.getValue(additionalComponent);
                if (additionalValue != null) {
                    final String additionalString = additionalValue.toString();
                    final String additionalUnit = ComponentUtilities.getComponentUnitLabel(additionalComponent);

                    if (!StringUtils.isBlank(additionalString))
                        formatter.addLine(additionalComponent.getName(), additionalString, additionalUnit);
                }
            }
        }

        /* comment if set */
        final IComponent commentComponent = profile.hasPointProperty(IWspmConstants.POINT_PROPERTY_COMMENT);
        if (commentComponent != null) {
            final String comment = point.getComment();
            if (!StringUtils.isBlank(comment))
                formatter.addFooter(comment);
        }

        return formatter.format();
    } catch (final RuntimeException e) {
        return e.getLocalizedMessage();
    }
}

From source file:org.exoplatform.utils.ExoConnectionUtils.java

public static String[] checkRequestTenant(HttpResponse response) {

    String[] results = new String[2];
    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK)
        return null;

    try {//from ww  w  . jav a 2  s  . c o  m
        String result = getPLFStream(response);
        JSONObject json = (JSONObject) JSONValue.parse(result);
        results[0] = json.get(ExoConstants.USERNAME).toString();
        results[1] = json.get(ExoConstants.TENANT).toString();
        Log.d(TAG, "user:   " + results[0] + " - tenant: " + results[1]);
        return results;
    } catch (RuntimeException e) {
        Log.d(TAG, "RuntimeException: " + e.getLocalizedMessage());
        return null;
    }
}

From source file:com.sabdroidex.controllers.couchpotato.CouchPotatoController.java

/**
 * Ignore a release// w  w w .  j av a 2s .  co  m
 * 
 * @param messageHandler Handler
 * @param releaseId ID of release to ignore
 */
public static void ignoreRelease(final Handler messageHandler, final int releaseId) {
    if (!Preferences.isSet(Preferences.COUCHPOTATO_URL)) {
        return;
    }

    Thread thread = new Thread() {

        @Override
        public void run() {

            try {
                String result = makeApiCall(MESSAGE.RELEASE_IGNORE.toString().toLowerCase(), "id=" + releaseId);
                JSONObject jsonObject = new JSONObject(result);
                Log.d(TAG, jsonObject.toString());

            } catch (RuntimeException e) {
                Log.w(TAG, " " + e.getLocalizedMessage());
            } catch (Throwable e) {
                Log.w(TAG, " " + e.getLocalizedMessage());
            }
        }
    };
    thread.start();
}

From source file:com.sabdroidex.controllers.couchpotato.CouchPotatoController.java

/**
 * This download the release information for a specific movie.
 *
 * @param messageHandler The message handler that will receive the result.
 * @param movieId The movie Id to get the information for.
 *//*  www  . j a va  2s  . co m*/
public static void getReleasesForMovie(final Handler messageHandler, final int movieId) {
    if (!Preferences.isSet(Preferences.COUCHPOTATO_URL)) {
        return;
    }

    Thread thread = new Thread() {

        @Override
        public void run() {

            try {
                String result = makeApiCall(MESSAGE.RELEASE_FOR_MOVIE.toString().toLowerCase(),
                        "id=" + movieId);
                JSONObject jsonObject = new JSONObject(result);
                MovieReleases movieReleases = null;

                if (!jsonObject.isNull("message") && !"".equals(jsonObject.getString("message"))) {
                    sendUpdateMessageStatus(messageHandler, "CouchPotato : " + jsonObject.getString("message"));
                } else {
                    SimpleJSONMarshaller jsonMarshaller = new SimpleJSONMarshaller(MovieReleases.class);
                    movieReleases = (MovieReleases) jsonMarshaller.unMarshal(jsonObject);
                }

                Message message = new Message();
                message.setTarget(messageHandler);
                message.what = MESSAGE.RELEASE_FOR_MOVIE.hashCode();
                message.obj = movieReleases;
                message.sendToTarget();
            } catch (RuntimeException e) {
                Log.w(TAG, " " + e.getLocalizedMessage());
            } catch (Throwable e) {
                Log.w(TAG, " " + e.getLocalizedMessage());
            }
        }
    };

    thread.start();
}

From source file:com.ibm.research.rdf.store.cmd.LoadRdfStore.java

@Override
public void doWork(Connection conn) {

    if (finalArg == null) {
        System.out.println("Load file not specified");
        printUsage();/*from w  w w  .j  a v a 2s. co m*/
        return;
    }

    try {

        Store store = StoreManager.connectStore(conn, Backend.valueOf(params.get("-backend")),
                params.get("-schema"), storeName, Context.defaultContext);
        Dataset db2DS = RdfStoreFactory.connectDataset(store, conn, Backend.valueOf(params.get("-backend")));

        //         Lang lang = Lang. Lang.guess(finalArg);
        //         long timeTaken;
        //         long numTriples = 0;
        //         if ( RDFLanguages.isQuads(lang) ) {
        //            timeTaken = loadQuads(conn,db2DS);
        //            numTriples =  StoreManager.getStoreSize(conn, params.get("-backend"), 
        //                  params.get("-schema"), storeName, Context.defaultContext);
        //         }
        //         else if ( RDFLanguages.isTriples(lang) ) {
        //            timeTaken = loadToDefault(conn,db2DS,finalArg,lang);
        //            numTriples = db2DS.getDefaultModel().size();
        //         }
        //         else {
        //            System.out.println("Unknown RDF type : " + finalArg);
        //            return;
        //         }
        //         
        //   
        //         
        //         System.out.println("Loaded "  + numTriples +
        //                  " triples in " + (timeTaken/ 1000 ) + " secs");
    } catch (RuntimeException e) {
        log.error(e);
        System.out.println(e.getLocalizedMessage());
    } catch (Exception e) {
        log.error(e);
        System.out.println(e.getLocalizedMessage());
    }

}

From source file:jenkins.plugins.publish_over.BPBuildEnv.java

private String safeGetNormalizedBaseDirectory() {
    if (baseDirectory == null)
        return null;
    try {//from  w ww  . java2s .c  o  m
        return getNormalizedBaseDirectory();
    } catch (RuntimeException re) {
        return re.getLocalizedMessage();
    }
}

From source file:jenkins.plugins.publish_over.BPBuildEnv.java

private String safeGetBuildTime() {
    if (buildTime == null)
        return null;
    try {//from  w ww . j a va2  s .  com
        return DateFormat.getDateTimeInstance().format(buildTime.getTime());
    } catch (RuntimeException re) {
        return re.getLocalizedMessage();
    }
}

From source file:com.aspose.showcase.qrcodegen.web.api.controller.RestResponseEntityExceptionHandler.java

@ExceptionHandler(value = { BarCodeException.class })
protected ResponseEntity<Object> handleConflict(RuntimeException ex, WebRequest request) {

    String bodyOfResponse = "Internal Server Error";
    HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;

    String detailMessage = ex.getLocalizedMessage();

    if (detailMessage == null) {
        bodyOfResponse = "Internal Server Error";
        httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;

    } else if (detailMessage.contains("evaluation version")) {

        bodyOfResponse = "Please upgrade to paid license to avail this feature. \n Internal Error - "
                + ex.getMessage();/*from  w  w w. ja  va  2s.c om*/
        httpStatus = HttpStatus.PAYMENT_REQUIRED;

    } else {
        bodyOfResponse = ex.getMessage();
        httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;

    }

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);

    return handleExceptionInternal(ex, bodyOfResponse, headers, httpStatus, request);
}

From source file:es.urjc.mctwp.image.management.ImagePluginManager.java

/**
 * Obtain a node for header image informacion
 * /*from  www  . ja v a 2  s. co  m*/
 * @param image
 * @return DOMNode
 * @throws ImageException
 */
public Node obtainNode(Image image) throws ImageException {
    Node result = null;

    List<ImagePlugin> lstPlugins = getPlugins(image);
    if (lstPlugins != null)
        for (ImagePlugin plugin : lstPlugins) {
            try {
                result = plugin.toXml(image);
                if (result != null)
                    break;
            } catch (RuntimeException re) {
                logger.error(re.getLocalizedMessage());
                re.printStackTrace();
            }
        }

    return result;
}