mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-07-01 03:34:21 +08:00
优化异常
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user