Package com.stormpath.samples.todos.error

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


                .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

    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

        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

TOP

Related Classes of com.stormpath.samples.todos.error.RestError

Copyright © 2018 www.massapicom. 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.