Commit b3039078 authored by Noel Alonso's avatar Noel Alonso
Browse files

Actualiza etiquetas de manejo de excepciones

Debido a una actualización de spring, las etiquetas no estaban teniendo
efecto, haciendo necesario sustituirlas por otras específicas para api
rest
parent 11279155
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -21,22 +21,19 @@ package es.redmic.restlib.exceptionhandler;
 */

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import es.redmic.exception.common.BadRequestException;
import es.redmic.exception.dto.ErrorDTO;
import es.redmic.exception.handler.BaseExceptionHandler;

@ControllerAdvice(annotations = RestController.class)
@RestControllerAdvice
public class BadRequestExceptionHandler extends BaseExceptionHandler {

	@ExceptionHandler(value = BadRequestException.class)
	@ResponseStatus(value = HttpStatus.BAD_REQUEST) // 400
	@ResponseBody
	public ErrorDTO handleBadRequestException(BadRequestException e) {
		return getError(e);
	}
+2 −5
Original line number Diff line number Diff line
@@ -21,22 +21,19 @@ package es.redmic.restlib.exceptionhandler;
 */

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import es.redmic.exception.common.ConflictException;
import es.redmic.exception.dto.ErrorDTO;
import es.redmic.exception.handler.BaseExceptionHandler;

@ControllerAdvice(annotations = RestController.class)
@RestControllerAdvice
public class ConflictExceptionHandler extends BaseExceptionHandler {

	@ExceptionHandler(value = ConflictException.class)
	@ResponseStatus(value = HttpStatus.CONFLICT) // 409
	@ResponseBody
	public ErrorDTO handleConflictException(ConflictException e) {
		return getError(e);
	}
+2 −5
Original line number Diff line number Diff line
@@ -21,22 +21,19 @@ package es.redmic.restlib.exceptionhandler;
 */

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import es.redmic.exception.common.InternalException;
import es.redmic.exception.dto.ErrorDTO;
import es.redmic.exception.handler.BaseExceptionHandler;

@ControllerAdvice(annotations = RestController.class)
@RestControllerAdvice
public class InternalServerExceptionHandler extends BaseExceptionHandler {

	@ExceptionHandler(value = InternalException.class)
	@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) // 500
	@ResponseBody
	public ErrorDTO handleNotFoundException(InternalException e) {
		return getError(e);
	}
+2 −5
Original line number Diff line number Diff line
@@ -21,21 +21,18 @@ package es.redmic.restlib.exceptionhandler;
 */

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import es.redmic.exception.common.NoContentException;
import es.redmic.exception.handler.BaseExceptionHandler;

@ControllerAdvice(annotations = RestController.class)
@RestControllerAdvice
public class NoContentExceptionHandler extends BaseExceptionHandler {

	@ExceptionHandler(value = NoContentException.class)
	@ResponseStatus(value = HttpStatus.NO_CONTENT) // 204
	@ResponseBody
	public void handleConflictException(NoContentException e) {
		return;
	}
+2 −5
Original line number Diff line number Diff line
@@ -21,22 +21,19 @@ package es.redmic.restlib.exceptionhandler;
 */

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import es.redmic.exception.common.MethodNotAllowedException;
import es.redmic.exception.dto.ErrorDTO;
import es.redmic.exception.handler.BaseExceptionHandler;

@ControllerAdvice(annotations = RestController.class)
@RestControllerAdvice
public class NotAllowedExceptionHandler extends BaseExceptionHandler {

	@ExceptionHandler(value = MethodNotAllowedException.class)
	@ResponseStatus(value = HttpStatus.METHOD_NOT_ALLOWED) // 405
	@ResponseBody
	public ErrorDTO handleNotFoundException(MethodNotAllowedException e) {
		return getError(e);
	}
Loading