Example usage for java.lang Exception getLocalizedMessage

List of usage examples for java.lang Exception getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:edu.cmu.tetrad.cli.AbstractApplicationCli.java

protected void parseOptions() {
    try {//w w  w.  j ava 2 s. c o m
        CommandLineParser cmdParser = new DefaultParser();
        CommandLine cmd = cmdParser.parse(MAIN_OPTIONS, args);
        parseCommonRequiredOptions(cmd);
        parseCommonOptionalOptions(cmd);
        parseRequiredOptions(cmd);
        parseOptionalOptions(cmd);
    } catch (Exception exception) {
        System.err.println(exception.getLocalizedMessage());
        System.exit(-127);
    }
}

From source file:com.kylinolap.job.hadoop.cube.CubeHFileJob.java

public int run(String[] args) throws Exception {
    Options options = new Options();

    try {//from   w  w w.  j  ava 2  s . com
        options.addOption(OPTION_JOB_NAME);
        options.addOption(OPTION_CUBE_NAME);
        options.addOption(OPTION_INPUT_PATH);
        options.addOption(OPTION_OUTPUT_PATH);
        options.addOption(OPTION_HTABLE_NAME);
        parseOptions(options, args);

        Path output = new Path(getOptionValue(OPTION_OUTPUT_PATH));
        String cubeName = getOptionValue(OPTION_CUBE_NAME).toUpperCase();

        CubeManager cubeMgr = CubeManager.getInstance(KylinConfig.getInstanceFromEnv());

        CubeInstance cube = cubeMgr.getCube(cubeName);
        job = Job.getInstance(getConf(), getOptionValue(OPTION_JOB_NAME));

        File JarFile = new File(KylinConfig.getInstanceFromEnv().getKylinJobJarPath());
        if (JarFile.exists()) {
            job.setJar(KylinConfig.getInstanceFromEnv().getKylinJobJarPath());
        } else {
            job.setJarByClass(this.getClass());
        }

        addInputDirs(getOptionValue(OPTION_INPUT_PATH), job);
        FileOutputFormat.setOutputPath(job, output);

        job.setInputFormatClass(SequenceFileInputFormat.class);
        job.setMapperClass(CubeHFileMapper.class);
        job.setReducerClass(KeyValueSortReducer.class);

        // set job configuration
        job.getConfiguration().set(BatchConstants.CFG_CUBE_NAME, cubeName);
        Configuration conf = HBaseConfiguration.create(getConf());
        // add metadata to distributed cache
        attachKylinPropsAndMetadata(cube, job.getConfiguration());

        String tableName = getOptionValue(OPTION_HTABLE_NAME).toUpperCase();
        HTable htable = new HTable(conf, tableName);
        HFileOutputFormat.configureIncrementalLoad(job, htable);

        // set block replication to 3 for hfiles
        conf.set(DFSConfigKeys.DFS_REPLICATION_KEY, "3");

        this.deletePath(job.getConfiguration(), output);

        return waitForCompletion(job);
    } catch (Exception e) {
        printUsage(options);
        log.error(e.getLocalizedMessage(), e);
        return 2;
    }
}

From source file:de.blizzy.documentr.web.access.AccessController.java

private String getMessage(Exception exception) {
    String msg = null;/*  w  w w  .j a v a 2s.  co  m*/
    if (exception != null) {
        msg = exception.getLocalizedMessage();
        if (StringUtils.isBlank(msg)) {
            msg = exception.getMessage();
        }
    }
    return msg;
}

From source file:org.kelvmiao.sevenwonders.client.controller.LoginController.java

@FXML
void onLogin(ActionEvent event) {
    String userId = txtUserId.getText();
    String pass = password.getText();
    if (userId.length() <= 0 || pass.length() <= 0) {
        Main.showAlert(Alert.AlertType.ERROR, "Input Error", null,
                "Please fill in your user name and password!");
        return;//from w w  w .  j av  a2s .  co  m
    }
    logger.trace("Logging in as " + userId);
    User user;
    try {
        RestTemplate template = new RestTemplate();
        user = template.postForObject(Main.getString("login.login-url"), new LoginRequest(userId, pass),
                User.class);
        logger.trace("Logged in as ID: " + user.getUid());
        Main.setAppData("user", user);
        Main.setAppData("offline-mode", false);
        Main.showMainStage("menu");
    } catch (Exception e) {
        logger.log(Level.WARN, e.getLocalizedMessage(), e);
        Main.showAlert(Alert.AlertType.ERROR, "Login Error", null,
                "Login failed, please check your user name and password!");
    }
}

From source file:de.luhmer.owncloudnewsreader.async_tasks.GetImageThreaded.java

public GetImageThreaded(String WEB_URL_TO_FILE, ImageDownloadFinished imgDownloadFinished, long ThreadId,
        String rootPath, Context cont) {
    try {// w  w w .j  av  a 2  s  .co m
        this.WEB_URL_TO_FILE = new URL(WEB_URL_TO_FILE);
    } catch (Exception ex) {
        Log.d(TAG, ex.getLocalizedMessage() + " - URL: " + WEB_URL_TO_FILE);
        //ex.printStackTrace();
    }

    this.cont = cont;
    imageDownloadFinished = imgDownloadFinished;
    this.ThreadId = ThreadId;
    this.rootPath = rootPath;
    //this.imageViewReference = new WeakReference<ImageView>(imageView);
}

From source file:com.ivyis.pentaho.ivygs.rest.PluginResource.java

private StreamingOutput toErrorResult(final Exception e) {
    log.error(e.getLocalizedMessage(), e);
    return new StreamingOutput() {
        public void write(OutputStream out) throws IOException, WebApplicationException {
            JsonHelper.writeJson(new JsonResult(false, e.getLocalizedMessage()), out);
        }//  w ww .  ja  v a 2 s  .  c o m
    };
}

From source file:com.kylinolap.job.hadoop.cube.FactDistinctColumnsJob.java

@Override
public int run(String[] args) throws Exception {
    Options options = new Options();

    try {/*from  ww w. j a va  2s  . c o  m*/
        options.addOption(OPTION_JOB_NAME);
        options.addOption(OPTION_CUBE_NAME);
        options.addOption(OPTION_INPUT_PATH);
        options.addOption(OPTION_INPUT_FORMAT);
        options.addOption(OPTION_OUTPUT_PATH);
        parseOptions(options, args);

        job = Job.getInstance(getConf(), getOptionValue(OPTION_JOB_NAME));
        String cubeName = getOptionValue(OPTION_CUBE_NAME);
        Path input = new Path(getOptionValue(OPTION_INPUT_PATH));
        String inputFormat = getOptionValue(OPTION_INPUT_FORMAT);
        Path output = new Path(getOptionValue(OPTION_OUTPUT_PATH));

        // ----------------------------------------------------------------------------

        job.getConfiguration().set(BatchConstants.CFG_CUBE_NAME, cubeName);
        System.out.println("Starting: " + job.getJobName());

        setupMapInput(input, inputFormat);
        setupReduceOutput(output);

        // add metadata to distributed cache
        CubeManager cubeMgr = CubeManager.getInstance(KylinConfig.getInstanceFromEnv());
        // CubeSegment seg = cubeMgr.getCube(cubeName).getTheOnlySegment();
        attachKylinPropsAndMetadata(cubeMgr.getCube(cubeName), job.getConfiguration());

        return waitForCompletion(job);

    } catch (Exception e) {
        printUsage(options);
        log.error(e.getLocalizedMessage(), e);
        return 2;
    }

}

From source file:edu.fullerton.framemonitor.ChangeListener.java

protected void logError(Exception ex) {
    String ermsg = ex.getClass().getSimpleName() + " - " + ex.getLocalizedMessage();
    logit(ermsg);//from ww  w.  ja  v a  2 s .c o  m
}

From source file:com.farsunset.cim.service.impl.JavaApnsServiceImpl.java

@SuppressWarnings("deprecation")
@Override//from   w w w.ja  va2s.co m
public void push(Message message, String deviceToken) {

    if (StringUtils.isBlank(deviceToken)) {
        return;
    }

    InputStream stream = getClass().getResourceAsStream(p12Path);
    ApnsChannelFactory apnsChannelFactory = Apns4j.newChannelFactoryBuilder().keyStoreMeta(stream)
            .keyStorePwd(password).apnsGateway(isDebug ? ApnsGateway.DEVELOPMENT : ApnsGateway.PRODUCTION)
            .build();

    ApnsChannel apnsChannel = apnsChannelFactory.newChannel();

    try {
        ApnsPayloadCompat apnsPayload = new ApnsPayloadCompat();
        apnsPayload.setAction(message.getAction());
        apnsPayload.setContent(message.getContent());
        apnsPayload.setSender(message.getSender());
        apnsPayload.setFormat(message.getFormat());
        apnsPayload.setReceiver(message.getReceiver());
        apnsChannel.send(deviceToken, apnsPayload);

        logger.info(deviceToken + "\r\ndata:" + apnsPayload.toJsonString());
    } catch (Exception e) {
        e.printStackTrace();
        logger.severe(e.getLocalizedMessage());
    } finally {
        apnsChannel.close();
        IOUtils.closeQuietly(stream);
    }
}

From source file:cn.com.inhand.devicenetworks.ap.mq.rabbitmq.DelivingNoticeConsumer.java

public void listen(Message message) {
    String str = new String(message.getBody());
    System.out.println("===============recv:" + message);
    try {/*  ww  w  . ja  v  a2  s .c o m*/
        DNMessage msg = parser.unwrap(str.getBytes());
        if (msg != null) {
            Parameter param = msg.getParameter("id");
            if (param != null) {
                String id = param.getValue();
                WebSocketSession ws = this.cinfo.getWssn(id);
                if (ws != null) {
                    ws.sendMessage(new TextMessage(str));
                } else {
                    //???Websocket AP?AP?AP???
                    //?
                    //                        List list = new ArrayList();
                    //                        list.add(new Parameter("result", "30005"));
                    //                        list.add(new Parameter("reason", "The asset is offline."));
                    //                        list.add(msg.getParameter("id"));
                    //                        list.add(msg.getParameter("transcation_id"));
                    //                        list.add(msg.getParameter("asset_id"));
                    //                        DNMessage ack = new DNMessage(msg.getName(), "response", msg.getTxid(), list);
                    //
                    //                        MessageProperties properties =message.getMessageProperties();
                    ////                        properties.setCorrelationId(correlationId);
                    //        
                    //                        producer.sendMessage(new String(parser.wrap(msg)));
                    //                        logger.info("The asset[" + asset_id + "] is not online, return a offline ack to source. msg=" + ack.toString());
                    //                        System.out.println("The asset[" + asset_id + "] is not online, return a offline ack to source. msg=" + ack.toString());
                    //                         //?rabbitmq rpc
                    //--------------------------------

                }
            } else {
                //??
            }
        }
    } catch (Exception e) {
        logger.warning(e.getLocalizedMessage());
    }
}