Examples of RestError


Examples of com.stormpath.samples.todos.error.RestError

    }

    @Override
    public Response toResponse(Throwable t) {
        //System.out.println("Throwable: " + t);
        RestError error = getRestError(t);
        return Response.status(Response.Status.fromStatusCode(error.getStatus().value()))
                .type(MediaType.APPLICATION_JSON_TYPE)
                .entity(error.toMap()).build();
    }
View Full Code Here

Examples of com.stormpath.samples.todos.error.RestError

                .entity(error.toMap()).build();
    }

    private RestError getRestError(Throwable t) {

        RestError template = getRestErrorTemplate(t);
        if (template == null) {
            return null;
        }

        RestError.Builder builder = new RestError.Builder();
        builder.setStatus(template.getStatus());
        builder.setCode(template.getCode());
        builder.setMoreInfoUrl(template.getMoreInfoUrl());
        builder.setThrowable(t);

        String msg = getMessage(template.getMessage(), t);
        if (msg != null) {
            builder.setMessage(msg);
        }
        msg = getMessage(template.getDeveloperMessage(), t);
        if (msg != null) {
            builder.setDeveloperMessage(msg);
        }

        return builder.build();
View Full Code Here

Examples of com.stormpath.samples.todos.error.RestError

    private RestError getRestErrorTemplate(Throwable t) {
        Map<String,RestError> mappings = this.exceptionMappings;
        if (mappings == null || mappings.isEmpty()) {
            return null;
        }
        RestError template = null;
        String dominantMapping = null;
        int deepest = Integer.MAX_VALUE;
        for (Map.Entry<String, RestError> entry : mappings.entrySet()) {
            String key = entry.getKey();
            int depth = getDepth(key, t);
View Full Code Here

Examples of com.stormpath.samples.todos.error.RestError

        Map<String, RestError> map = new LinkedHashMap<String, RestError>(smap.size());

        for (Map.Entry<String, String> entry : smap.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            RestError template = toRestError(value);
            map.put(key, template);
        }

        return map;
    }
View Full Code Here

Examples of org.apache.camel.component.salesforce.api.dto.RestError

                        // parse the response to get error
                        final LoginError error = objectMapper.readValue(responseContent, LoginError.class);
                        final String msg = String.format("Login error code:[%s] description:[%s]",
                                error.getError(), error.getErrorDescription());
                        final List<RestError> errors = new ArrayList<RestError>();
                        errors.add(new RestError(msg, error.getErrorDescription()));
                        throw new SalesforceException(errors, HttpStatus.BAD_REQUEST_400);

                    default:
                        throw new SalesforceException(String.format("Login error status:[%s] reason:[%s]",
                            responseStatus, loginPost.getReason()), responseStatus);
View Full Code Here

Examples of org.apache.camel.component.salesforce.api.dto.RestError

        // this must be of type Error
        try {
            final Error error = unmarshalResponse(new ByteArrayInputStream(request.getResponseContentBytes()),
                    request, Error.class);

            final RestError restError = new RestError();
            restError.setErrorCode(error.getExceptionCode());
            restError.setMessage(error.getExceptionMessage());

            return new SalesforceException(Arrays.asList(restError), request.getResponseStatus());
        } catch (SalesforceException e) {
            String msg = "Error un-marshaling Salesforce Error: " + e.getMessage();
            return new SalesforceException(msg, e);
View Full Code Here

Examples of org.apache.camel.component.salesforce.api.dto.RestError

                        // parse the response to get error
                        final LoginError error = objectMapper.readValue(responseContent, LoginError.class);
                        final String msg = String.format("Login error code:[%s] description:[%s]",
                                error.getError(), error.getErrorDescription());
                        final List<RestError> errors = new ArrayList<RestError>();
                        errors.add(new RestError(msg, error.getErrorDescription()));
                        throw new SalesforceException(errors, HttpStatus.BAD_REQUEST_400);

                    default:
                        throw new SalesforceException(String.format("Login error status:[%s] reason:[%s]",
                            responseStatus, loginPost.getReason()), responseStatus);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.