优化异常

This commit is contained in:
zhou-hao
2020-08-19 15:19:22 +08:00
parent 23db12b697
commit ac557ce7fd
2 changed files with 13 additions and 3 deletions

View File

@@ -18,9 +18,11 @@
package org.hswebframework.web.exception;
/**
*
*/
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND)
public class NotFoundException extends BusinessException {
public NotFoundException(String message) {
super(message, 404);

View File

@@ -3,14 +3,18 @@ package org.hswebframework.web.exception;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.validation.ConstraintViolation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@Getter
@Setter
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class ValidationException extends BusinessException {
private List<Detail> details;
@@ -19,6 +23,10 @@ public class ValidationException extends BusinessException {
super(message);
}
public ValidationException(String property, String message) {
this(message, Collections.singletonList(new Detail(property, message, null)));
}
public ValidationException(String message, List<Detail> details) {
super(message);
this.details = details;