package com.dbs.consentServer.handler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

@ControllerAdvice  
@RestController
public class GlobalExceptionHandler {

  private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
  @ExceptionHandler(Exception.class)
  protected List<Map<String, String>> handleException(Exception e) {
    ArrayList<Map<String, String>> arResponse = new ArrayList<Map<String, String>>();
    HashMap<String, String> response = new HashMap<String, String>();
    response.put("code", "99");
    response.put("errorMsg", e.getMessage());
    arResponse.add(response);
    
    return arResponse;
  }
}
