Feature #5 申请友链时自动抓取网页信息 #6

Merged
xiaohai2271 merged 21 commits from feature-#5 into dev 2020-08-01 21:24:47 +08:00
2 changed files with 10 additions and 8 deletions
Showing only changes of commit dcf44cefb6 - Show all commits

View File

@@ -39,8 +39,9 @@ public class ExceptionHandle {
public Response handle(Exception e) { public Response handle(Exception e) {
//自定义错误 //自定义错误
if (e instanceof MyException) { if (e instanceof MyException) {
logger.debug("返回了自定义的exception,[code={},msg={}]", ((MyException) e).getCode(), e.getMessage()); MyException exception = (MyException) e;
return new Response(((MyException) e).getCode(), e.getMessage(), null); logger.debug("返回了自定义的exception,[code={},msg={},result={}]", exception.getCode(), e.getMessage(), exception.getResult());
return new Response(exception.getCode(), e.getMessage(), exception.getResult());
} }
//请求路径不支持该方法 //请求路径不支持该方法
if (e instanceof HttpRequestMethodNotSupportedException) { if (e instanceof HttpRequestMethodNotSupportedException) {

View File

@@ -1,13 +1,16 @@
package cn.celess.blog.exception; package cn.celess.blog.exception;
import cn.celess.blog.enmu.ResponseEnum; import cn.celess.blog.enmu.ResponseEnum;
import lombok.Data;
/** /**
* @author : xiaohai * @author : xiaohai
* @date : 2019/03/28 16:56 * @date : 2019/03/28 16:56
*/ */
@Data
public class MyException extends RuntimeException { public class MyException extends RuntimeException {
private int code; private int code;
private Object result;
public MyException(int code, String msg) { public MyException(int code, String msg) {
super(msg); super(msg);
@@ -24,11 +27,9 @@ public class MyException extends RuntimeException {
this.code = e.getCode(); this.code = e.getCode();
} }
public int getCode() { public MyException(ResponseEnum e, String msg, Object result) {
return code; super(e.getMsg());
} this.code = e.getCode();
this.result = result;
public void setCode(int code) {
this.code = code;
} }
} }