package com.sequenceiq.environment.exception.mapper;

import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Providers;

public abstract class SearchCauseExceptionMapper<T extends Throwable> extends BaseExceptionMapper<T> {

    @Context
    private Providers providers;

    @Override
    Response.Status getResponseStatus(T exception) {
        BaseExceptionMapper exceptionMapper = (BaseExceptionMapper<? extends Throwable>) providers.getExceptionMapper(exception.getCause().getClass());
        if (exceptionMapper == null) {
            return Response.Status.BAD_REQUEST;
        }
        return exceptionMapper.getResponseStatus(exception.getCause());
    }
}

@@ -363,24 +363,239 @@
 xception) %7B%0A
+        Response.Status defaultResponse = Response.Status.BAD_REQUEST;%0A        if (exception.getCause() != null && Exception.class == exception.getCause().getClass()) %7B%0A            return defaultResponse;%0A        %7D%0A
         Base
@@ -792,24 +792,31 @@
  return 
+default
 Response
 .Status.
@@ -807,35 +807,16 @@
 Response
-.Status.BAD_REQUEST
 ;%0A      

CB-10389 Internal server error occurred if the cause exception is Exception