ResourceNotFoundException.java 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
package ec.edu.espe.movilidad.MovilidadWS.Exceptions;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;


@ResponseStatus(value = HttpStatus.NOT_FOUND) //cuando no se encuentre un registro
public class ResourceNotFoundException extends RuntimeException{

    public ResourceNotFoundException(String message) {
        super(message);
    }

    @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) // error interno del servidor
    public static class InternalServerErrorException extends RuntimeException {
        public InternalServerErrorException(String message) {
            super(message);
        }
    }
    @ResponseStatus(value = HttpStatus.UNAUTHORIZED) // no autorizado
    public static class UnauthorizedException extends RuntimeException {
        public UnauthorizedException(String message) {
            super(message);
        }
    }

    @ResponseStatus(value = HttpStatus.BAD_REQUEST) // solicitud incorrecta
    public static class ValidationException extends RuntimeException {
        public ValidationException(String message) {
            super(message);
        }
    }

    @ResponseStatus(value = HttpStatus.NOT_FOUND) // acceso a datos incorrecto
    public static class DataAccessException extends RuntimeException {
        public DataAccessException(String message) {
            super(message);
        }
    }

}