/**
 * Copyright (c) 2013-2016, The SeedStack authors <http://seedstack.org>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.seedstack.seed.web.internal.diagnostic;

import org.seedstack.seed.diagnostic.DiagnosticManager;
import org.seedstack.seed.SeedException;
import org.seedstack.seed.web.internal.ServletContextUtils;
import org.seedstack.seed.web.internal.WebErrorCode;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

public class WebDiagnosticFilter implements Filter {
    private DiagnosticManager diagnosticManager;

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        diagnosticManager = ServletContextUtils.getInjector(filterConfig.getServletContext()).getInstance(DiagnosticManager.class);
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        try {
            chain.doFilter(request, response);
        } catch (SeedException e) {
            diagnosticManager.dumpDiagnosticReport(e);
            throw e;
        } catch (Exception e) {
            diagnosticManager.dumpDiagnosticReport(e);
            throw SeedException.wrap(e, WebErrorCode.UNEXPECTED_EXCEPTION);
        }
    }

    @Override
    public void destroy() {
        // nothing to do here
    }
}

@@ -362,77 +362,73 @@
 eed.
-diagnostic.DiagnosticManager;%0Aimport org.seedstack.seed.SeedException
+core.Seed;%0Aimport org.seedstack.seed.diagnostic.DiagnosticManager
 ;%0Aim
@@ -511,37 +511,35 @@
 ck.s
-eed.web.internal.WebErrorCode
+hed.exception.BaseException
 ;%0A%0Ai
@@ -1333,20 +1333,16 @@
  catch (
-Seed
 Exceptio
@@ -1364,89 +1364,49 @@
     
-diagnosticManager.dumpDiagnosticReport(e);%0A            throw e;%0A        %7D catch (
+BaseException translated = Seed.translate
 Exce
@@ -1402,37 +1402,36 @@
 anslateException
- e) %7B
+(e);
 %0A            dia
@@ -1466,17 +1466,26 @@
 cReport(
-e
+translated
 );%0A     
@@ -1501,64 +1501,18 @@
 row 
-SeedException.wrap(e, WebErrorCode.UNEXPECTED_EXCEPTION)
+translated
 ;%0A  

Translate exceptions in web request diagnostic