// Path: src/main/java/me/itzg/mccy/types/MccyClientException.java
// public abstract class MccyClientException extends MccyException {
//     public MccyClientException() {
//     }
// 
//     public MccyClientException(String message) {
//         super(message);
//     }
// 
//     public MccyClientException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public MccyClientException(Throwable cause) {
//         super(cause);
//     }
// }


import com.spotify.docker.client.exceptions.DockerRequestException;
import me.itzg.mccy.model.FailedRequest;
import me.itzg.mccy.types.MccyClientException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
package me.itzg.mccy.controllers;


/**
 * @author Geoff Bourne
 * @since 12/21/2015
 */
@ControllerAdvice(basePackageClasses = ErrorAdvice.class)
public class ErrorAdvice {

    @ExceptionHandler
    public ResponseEntity<?> handleDockerClientException(DockerRequestException e) {
        return ResponseEntity.badRequest()
                .body(new FailedRequest(e.getClass(), e.message()));
    }

    @ExceptionHandler
    public ResponseEntity<?> handleDockerClientException(IllegalArgumentException e) {
        return ResponseEntity.badRequest()
                .body(new FailedRequest(e.getClass(), e.getMessage()));
    }

    @ExceptionHandler
// Path: src/main/java/me/itzg/mccy/types/MccyClientException.java
// public abstract class MccyClientException extends MccyException {
//     public MccyClientException() {
//     }
// 
//     public MccyClientException(String message) {
//         super(message);
//     }
// 
//     public MccyClientException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public MccyClientException(Throwable cause) {
//         super(cause);
//     }
// }


// Path: src/main/java/me/itzg/mccy/controllers/ErrorAdvice.java
import com.spotify.docker.client.exceptions.DockerRequestException;
import me.itzg.mccy.model.FailedRequest;
import me.itzg.mccy.types.MccyClientException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

package me.itzg.mccy.controllers;


/**
 * @author Geoff Bourne
 * @since 12/21/2015
 */
@ControllerAdvice(basePackageClasses = ErrorAdvice.class)
public class ErrorAdvice {

    @ExceptionHandler
    public ResponseEntity<?> handleDockerClientException(DockerRequestException e) {
        return ResponseEntity.badRequest()
                .body(new FailedRequest(e.getClass(), e.message()));
    }

    @ExceptionHandler
    public ResponseEntity<?> handleDockerClientException(IllegalArgumentException e) {
        return ResponseEntity.badRequest()
                .body(new FailedRequest(e.getClass(), e.getMessage()));
    }

    @ExceptionHandler
    public ResponseEntity<?> handleDockerClientException(MccyClientException e) {