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:org.openwms.core.http.AbstractWebController.java

/**
 * All general exceptions thrown by services are caught here and translated into http conform responses with a status code {@code 500
 * Internal Server Error}.// w w  w .jav a  2  s.c o m
 *
 * @param ex The exception occurred
 * @return A response object wraps the server result
 */
@ExceptionHandler(Exception.class)
public ResponseEntity<Response<Serializable>> handleException(Exception ex) {
    EXC_LOGGER.error("[P] Presentation Layer Exception: " + ex.getLocalizedMessage(), ex);
    if (ex instanceof BehaviorAwareException) {
        BehaviorAwareException bae = (BehaviorAwareException) ex;
        return bae.toResponse(bae.getData());
    }
    if (ex instanceof BusinessRuntimeException) {
        BusinessRuntimeException bre = (BusinessRuntimeException) ex;
        return new ResponseEntity<>(new Response<>(ex.getMessage(), bre.getMsgKey(),
                HttpStatus.INTERNAL_SERVER_ERROR.toString(), new String[] { bre.getMsgKey() }),
                HttpStatus.INTERNAL_SERVER_ERROR);
    }
    if (ex instanceof HttpBusinessException) {
        HttpBusinessException e = (HttpBusinessException) ex;
        return new ResponseEntity<>(new Response<>(ex.getMessage(), e.getHttpStatus().toString()),
                e.getHttpStatus());
    }
    if (ex instanceof ValidationException) {
        return new ResponseEntity<>(new Response<>(ex.getMessage(), HttpStatus.BAD_REQUEST.toString()),
                HttpStatus.BAD_REQUEST);
    }
    if (ex instanceof TechnicalRuntimeException) {
        TechnicalRuntimeException be = (TechnicalRuntimeException) ex;
        return new ResponseEntity<>(new Response<>(ex.getMessage(), HttpStatus.BAD_GATEWAY.toString()),
                HttpStatus.BAD_GATEWAY);
    }
    return new ResponseEntity<>(new Response<>(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.toString()),
            HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:com.amalto.workbench.actions.XSDCopyConceptAction.java

public void run() {
    try {/*from  www . j  a v  a  2s  .  com*/
        WorkbenchClipboard.getWorkbenchClipboard().conceptsReset();
        WorkbenchClipboard.getWorkbenchClipboard().particlesReset();
        IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
        if (selection.getFirstElement() instanceof XSDElementDeclaration) {
            for (Iterator<XSDElementDeclaration> iter = selection.iterator(); iter.hasNext();) {
                XSDElementDeclaration concept = iter.next();

                if (concept instanceof XSDElementDeclaration)
                    WorkbenchClipboard.getWorkbenchClipboard().add(concept);
            }
        } else if (selection.getFirstElement() instanceof XSDParticle) {
            for (Iterator<XSDParticle> iter = selection.iterator(); iter.hasNext();) {
                XSDParticle particle = iter.next();

                if (particle instanceof XSDParticle)
                    WorkbenchClipboard.getWorkbenchClipboard().add(particle);
            }
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error,
                Messages.bind(Messages.XSDCopyConceptAction_ErrorMsg, e.getLocalizedMessage()));

    }
    // return true;
}

From source file:MockFedoraIT.java

private IrodsIFileSystem getModule() {
    IrodsIFileSystem result = null;/*from  w  ww .  j  av a 2  s.  com*/
    try {
        IRODSAccount account = new IRODSAccount("ono-sendai", 1247, "fedora", "inst1repo",
                "/count0Zone/home/fedora", "count0Zone", "count0Resc");
        IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance();
        result = new IrodsIFileSystem(32768, irodsFileSystem, account);
    } catch (Exception e) {
        e.printStackTrace();
        fail("got an exception:" + e.getLocalizedMessage());
    }
    System.out.println("module loaded");
    return result;
}

From source file:com.datatorrent.contrib.kafka.KafkaOperatorTestBase.java

public void startZookeeper(final int clusterId) {

    try {/*from  ww w  .  jav a  2  s  .com*/
        //before start, clean the zookeeper files if it exists
        FileUtils.deleteQuietly(new File(baseDir, zkBaseDir));
        int clientPort = TEST_ZOOKEEPER_PORT[clusterId];
        int numConnections = 10;
        int tickTime = 2000;
        File dir = new File(baseDir, zkdir[clusterId]);

        TestZookeeperServer kserver = new TestZookeeperServer(dir, dir, tickTime);
        zkFactory[clusterId] = new NIOServerCnxnFactory();
        zkFactory[clusterId].configure(new InetSocketAddress(clientPort), numConnections);

        zkFactory[clusterId].startup(kserver); // start the zookeeper server.
        Thread.sleep(2000);
        kserver.startup();
    } catch (Exception ex) {
        logger.debug(ex.getLocalizedMessage());
    }
}

From source file:com.datatorrent.contrib.kafka.KafkaOperatorTestBase.java

@After
public void afterTest() {
    try {/*w w w.j av  a 2 s . c om*/
        stopKafkaServer();
        stopZookeeper();
    } catch (Exception ex) {
        logger.debug("LSHIL {}", ex.getLocalizedMessage());
    }
}

From source file:com.googlecode.ouvidoria.presentation.complaint.register.RegisterComplaintCTLImpl.java

/**
 * @see com.googlecode.ouvidoria.presentation.complaint.internet.register.RegisterComplaintCTL#registerComplaint(java.lang.Long
 *      demandantType, java.lang.String name, java.lang.Long sex,
 *      java.lang.Long identification, java.lang.String document,
 *      java.lang.String businessPhone, java.lang.String celularPhone,
 *      java.lang.String email, java.lang.String address, java.lang.String
 *      zipCode, java.lang.Long state, java.lang.Long city, java.lang.Long
 *      type, java.lang.Long subject, java.lang.Long answer,
 *      java.lang.String text)//from   w w  w . j a va2  s  .c om
 */
@Override
public void registerComplaint(RegisterComplaintForm form) {
    log.info("registerComplaint ...");
    try {
        ComplaintVO complaintVO = toComplaintVO(form);
        SimpleComplaintVO saved = getComplaintService().save(complaintVO);
        form.setCode(String.format("%05d", saved.getId()));
        form.setPassword(saved.getPassword());
    } catch (Exception e) {
        // TODO mostrar mensagem de erro
        e.printStackTrace();
        throw new RuntimeException("ERRO: " + e.getLocalizedMessage(), e);
    }
}

From source file:com.epam.dlab.configuration.SchedulerConfiguration.java

/** Return time array of user' schedule time.
 * @param time the time in format HH:mm:ss.
 * @throws ParseException//  w  w w  .  j  ava  2  s. c  om
 */
private int[] getTime(String time) throws ParseException {
    String[] timeString = time.trim().split(":");
    int[] timeInt = new int[3];

    for (int i = 0; i < timeInt.length; i++) {
        if (i < timeString.length) {
            try {
                timeInt[i] = Integer.parseInt(timeString[i]);
            } catch (Exception e) {
                throw new ParseException("Cannot parse date " + time + ". " + e.getLocalizedMessage(), e);
            }
        } else {
            timeInt[i] = 0;
        }
    }

    return timeInt;
}

From source file:org.openxdata.server.servlet.FormDownloadServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    OutputStream os = response.getOutputStream();
    try {//from  w ww. j a  v  a  2 s .c  o m
        String action = request.getParameter(OpenXDataConstants.REQUEST_PARAMETER_ACTION);

        if (action == null)
            formsServer.processConnection(request.getInputStream(), os);
        else {

            User user = authenticationService.authenticate(
                    request.getParameter(OpenXDataConstants.REQUEST_PARAM_USERNAME),
                    request.getParameter(OpenXDataConstants.REQUEST_PARAM_PASSWORD));
            if (user == null) {
                response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
                XformSerializer formSerializer = serializationService.getFormSerializer(
                        request.getParameter(OpenXDataConstants.REQUEST_PARAM_FORM_SERIALIZER));
                formSerializer.serializeAccessDenied(os);
            } else {
                if (OpenXDataConstants.REQUEST_ACTION_UPLOAD_DATA.equalsIgnoreCase(action)) {
                    uploadData(request, response);
                    String serializerKey = request
                            .getParameter(OpenXDataConstants.REQUEST_PARAM_FORM_SERIALIZER);
                    XformSerializer formSerializer = serializationService.getFormSerializer(serializerKey);
                    formSerializer.serializeSuccess(os);
                } else if (OpenXDataConstants.REQUEST_ACTION_DOWNLOAD_FORMS.equalsIgnoreCase(action))
                    downloadForms(request, response);
                else if (OpenXDataConstants.ACTION_DOWNLOAD_STUDIES.equalsIgnoreCase(action))
                    downloadStudies(request, response);
                else if (OpenXDataConstants.REQUEST_ACTION_DOWNLOAD_USERS.equalsIgnoreCase(action))
                    downloadUsers(request, response);
            }
        }
    } catch (Exception ex) {
        try {
            String serializerKey = request.getParameter(OpenXDataConstants.REQUEST_PARAM_FORM_SERIALIZER);
            XformSerializer formSerializer = serializationService.getFormSerializer(serializerKey);
            formSerializer.serializeFailure(os, ex);
        } catch (Exception e) {
            log.error(e.getLocalizedMessage(), e);
        }
    }
}

From source file:be.ac.ua.comp.scarletnebula.gui.keywizards.FinalNewKeyPage.java

@Override
protected void performAction(final KeyRecorder recorder) {
    recorder.keyname = keyname;//  ww w. jav  a  2 s.  c o  m
    recorder.makeDefault = makeKeyDefault();

    (new SwingWorker<Exception, Object>() {
        @Override
        protected Exception doInBackground() throws Exception {
            try {
                provider.createKey(keyname, makeKeyDefault());
            } catch (final Exception e) {
                return e;
            }
            return null;
        }

        @Override
        public void done() {
            try {
                final Exception result = get();

                if (result != null) {
                    log.error("Could not create key", result);
                    JOptionPane.showMessageDialog(FinalNewKeyPage.this, result.getLocalizedMessage(),
                            "Error creating key", JOptionPane.ERROR_MESSAGE);
                }
            } catch (final Exception ignore) {
            }
        }
    }).execute();
}

From source file:org.amanzi.splash.editors.SplashJFreePieChartEditor.java

/**
 * @see org.eclipse.ui.IEditorPart#doSave(IProgressMonitor)
 *///  w w w  .j  av a 2s .c o  m
public void doSave(IProgressMonitor monitor) {
    try {
        if (validateEditorInput(getEditorInput()) != null) {
            if (getEditorInput().exists()) {
            }
            //                  saveContents();
            else {
                doSaveAs(MessageFormat.format("The original input ''{0}'' has been deleted.",
                        new Object[] { getEditorInput().getName() }));
            }
        } else {
            doSaveAs();
        }
    } catch (Exception e) {
        monitor.setCanceled(true);
        MessageDialog.openError(null, "Unable to Save Changes", e.getLocalizedMessage());
        return;
    }
}