class RestExceptionHandler extends ResponseEntityExceptionHandler {

    @ExceptionHandler
    ResponseEntity handle(ErrorResponseException exception) {
        logError(exception);
        HttpHeaders responseHeaders = addErrorOriginationHeader(
                headersMapper.toHttpHeaders(exception.getResponseHeaders()),
                ErrorOrigination.BANK
        );
        HttpStatus status = HttpStatus.valueOf(exception.getStatusCode());

        return exception.getErrorResponse()
                       .map(response -> {
                           String originalResponse = exception.getMessage();
                           if (response.getTppMessages() == null && response.getLinks() == null
                               && originalResponse != null && !originalResponse.isEmpty()) {
                               return new ResponseEntity<>(originalResponse, responseHeaders, status);
                           }
                           return new ResponseEntity<>(response, responseHeaders, status);
                       })
                       .orElseGet(() -> new ResponseEntity<>(responseHeaders, status));
    }

    public  RestExceptionHandler(HeadersMapper headersMapper);

}