Example usage for java.lang Throwable getLocalizedMessage

List of usage examples for java.lang Throwable getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.raywenderlich.reposearch.MainActivity.java

private void makeRetrofitCalls() {
    Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.github.com") // 1
            .addConverterFactory(GsonConverterFactory.create()) // 2
            .build();//from w  ww.  j av  a  2 s. co m

    RetrofitAPI retrofitAPI = retrofit.create(RetrofitAPI.class); // 3

    Call<ArrayList<Repository>> call = retrofitAPI.retrieveRepositories(); // 4

    call.enqueue(new Callback<ArrayList<Repository>>() { // 5
        @Override
        public void onResponse(Call<ArrayList<Repository>> call, Response<ArrayList<Repository>> response) {
            downloadComplete(response.body()); // 6
        }

        @Override
        public void onFailure(Call<ArrayList<Repository>> call, Throwable t) {
            Toast.makeText(MainActivity.this, t.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
        }
    });
}

From source file:com.jaspersoft.android.jaspermobile.dialog.PasswordDialogFragment.java

@NonNull
@Override//  w w w .j a  v a 2 s  .c om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    dialogView = inflater.inflate(R.layout.dialog_password, null);
    mGetCurrentProfileFormUseCase.execute(new SimpleSubscriber<ProfileForm>() {
        @Override
        public void onError(Throwable e) {
            showError(e.getLocalizedMessage());
        }

        @Override
        public void onNext(ProfileForm form) {
            populateForm(form);
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.h_ad_title_server_sign_in).setIcon(android.R.drawable.ic_dialog_alert)
            .setView(dialogView).setCancelable(true).setPositiveButton(R.string.ok, null)
            .setNegativeButton(R.string.cancel, null);

    AlertDialog dialog = builder.create();
    dialog.setOnShowListener(this);

    return dialog;
}

From source file:com.anrisoftware.prefdialog.dialogaction.AbstractDialogActionLogger.java

DialogActionException errorCreateDialog(AbstractDialogAction<?, ?> action, InvocationTargetException e) {
    Throwable cause = e.getCause();
    return logException(new DialogActionException(error_create_dialog, cause).add(action, action),
            error_create_dialog_message, cause.getLocalizedMessage());
}

From source file:com.fortify.processrunner.RunProcessRunnerFromSpringConfig.java

/**
 * Run the {@link AbstractProcessRunner} instance defined in the configuration file.
 * The {@link AbstractProcessRunner} will be run once for every {@link Context} 
 * returned by our {@link #getContexts(Context)} method.
 * @param cliOptionDefinitions// w w w  .j  a  va 2 s.  com
 * @param initialContext
 */
public void run(CLIOptionDefinitions cliOptionDefinitions, Context initialContext) {
    AbstractProcessRunner runner = getProcessRunner();
    Collection<Context> contexts = getContexts(initialContext);
    for (Context context : contexts) {
        try {
            checkContext(cliOptionDefinitions, context);
            runner.run(context);
        } catch (Throwable t) {
            LOG.error("[Process] Error during process run: " + t.getLocalizedMessage(), t);
        }
    }
    LOG.info("[Process] Processing complete");
}

From source file:org.bedework.eventreg.web.AbstractController.java

protected ModelAndView errorReturn(final Throwable t) {
    return errorReturn(t.getLocalizedMessage());
}

From source file:org.xcmis.search.SearchService.java

/**
 * @see org.xcmis.search.query.Searcher#execute(org.xcmis.search.model.Query,
 *      java.util.Map, org.xcmis.search.content.command.InvocationContext)
 *//*from  ww w.j  a  v  a  2 s  . com*/
@SuppressWarnings("unchecked")
public List<ScoredRow> execute(Query query, Map<String, Object> bindVariablesValues,
        InvocationContext invocationContext) throws InvalidQueryException, QueryExecutionException {
    ProcessQueryCommand processQueryCommand = new ProcessQueryCommand(query, bindVariablesValues);

    try {
        return (List<ScoredRow>) interceptorChain.invoke(invocationContext, processQueryCommand);
    } catch (Throwable e) {
        throw new InvalidQueryException(e.getLocalizedMessage(), e);
    }
}

From source file:org.deegree.maven.XMLCatalogueMojo.java

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    File target = new File(project.getBasedir(), "target");
    target.mkdirs();/*from ww w . ja v  a  2  s  .c  o  m*/
    target = new File(target, "deegree.xmlcatalog");

    PrintStream catalogOut = null;
    try {
        catalogOut = new PrintStream(new FileOutputStream(target), true, "UTF-8");
        final PrintStream catalog = catalogOut;

        addDependenciesToClasspath(project, artifactResolver, artifactFactory, metadataSource, localRepository);

        final XMLInputFactory fac = XMLInputFactory.newInstance();
        final Reflections r = new Reflections("/META-INF/schemas/");

        class CurrentState {
            String location;
        }

        final CurrentState state = new CurrentState();

        r.collect("META-INF/schemas", new Predicate<String>() {
            @Override
            public boolean apply(String input) {
                state.location = input;
                return input != null && input.endsWith(".xsd");
            }
        }, new Serializer() {
            @Override
            public Reflections read(InputStream in) {
                try {
                    XMLStreamReader reader = fac.createXMLStreamReader(in);
                    nextElement(reader);
                    String location = "classpath:META-INF/schemas/" + state.location;
                    String ns = reader.getAttributeValue(null, "targetNamespace");
                    catalog.println("PUBLIC \"" + ns + "\" \"" + location + "\"");
                } catch (Throwable e) {
                    getLog().error(e);
                }
                return r;
            }

            @Override
            public File save(Reflections reflections, String filename) {
                return null;
            }

            @Override
            public String toString(Reflections reflections) {
                return null;
            }
        });
    } catch (Throwable t) {
        throw new MojoFailureException("Creating xml catalog failed: " + t.getLocalizedMessage(), t);
    } finally {
        closeQuietly(catalogOut);
    }
}

From source file:net.vershinin.flashmind.FlashExportWizard.java

@Override
protected void handleExportException(Throwable e) {
    super.handleExportException(e);
    page.setErrorMessage(e.getLocalizedMessage());
}

From source file:net.geoprism.data.importer.ExcelController.java

@Override
public void importExcelFile(MultipartFileParameter file, String country, String downloadToken)
        throws IOException, ServletException {
    // The reason we're including a cookie here is because the browser does not give us any indication of when our
    // response from the server is successful and its downloading the file.
    // This "hack" sends a downloadToken to the client, which the client then checks for the existence of every so
    // often. When the cookie exists, it knows its downloading it.
    // http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download

    Cookie cookie = new Cookie("downloadToken", downloadToken);
    cookie.setMaxAge(10 * 60); // 10 minute cookie expiration
    resp.addCookie(cookie);/*ww  w  . j a  va 2  s . c o  m*/

    try {
        if (file == null) {
            throw new RuntimeException(
                    LocalizationFacadeDTO.getFromBundles(this.getClientRequest(), "file.required"));
        }

        InputStream istream = file.getInputStream();

        try {
            InputStream result = ExcelUtilDTO.importExcelFile(this.getClientRequest(), istream, country);

            if (result != null) {
                // copy it to response's OutputStream
                this.resp.setContentType("application/xlsx");
                this.resp.setHeader("Content-Disposition",
                        "attachment; filename=\"" + file.getFilename() + "\"");

                IOUtils.copy(result, this.resp.getOutputStream());
            } else {
                this.resp.getWriter().print("<p id=\"upload_result\" class=\"success\"></p>");
            }

            this.resp.flushBuffer();
        } finally {
            istream.close();
        }
    } catch (Throwable t) {
        this.resp.getWriter()
                .print("<p id=\"upload_result\" class=\"error\">" + t.getLocalizedMessage() + "</p>");
    }
}

From source file:pt.webdetails.cns.service.NotificationEngine.java

public boolean notify(INotificationEvent e) {
    if (e == null) {
        logger.error("INotificationEvent cannot be null");
        return false;
    }//from ww w . ja  v  a 2s. com

    try {

        getAsyncEventBus().post(e);
        return true;

    } catch (Throwable t) {
        logger.error(t.getLocalizedMessage(), t);
    }
    return false;
}