package org.deeplearning4j.ui.exception;


import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;


@Provider
public class GenericExceptionMapper implements ExceptionMapper<Throwable> {

    @Override
    public Response toResponse(Throwable ex) {
        return Response.status(500)
                .entity("Error occurred")
                .type(MediaType.APPLICATION_JSON)
                .build();
    }

}
package org.deeplearning4j.ui.exception;


import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

import org.apache.commons.lang.exception.ExceptionUtils;


@Provider
public class GenericExceptionMapper implements ExceptionMapper<Throwable> {

    @Override
    public Response toResponse(Throwable ex) {
        return Response.status(500)
                .entity("Error occurred\n\n" + (ex != null ? ExceptionUtils.getStackTrace(ex) : ""))
                .type(MediaType.APPLICATION_JSON)
                .build();
    }

}
Print exception details for UI
Print exception details for UI


Former-commit-id: 1433ca9b57894491926f5e10a8c9bc8e068020ba