mirror of https://github.com/halo-dev/halo
refactor: JSON serialize exception (#2222)
parent
2afe19f1b9
commit
73d43cae64
|
@ -0,0 +1,30 @@
|
|||
package run.halo.app.infra.utils;
|
||||
|
||||
/**
|
||||
* {@link JsonParseException} thrown when source JSON is invalid.
|
||||
*
|
||||
* @author guqing
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class JsonParseException extends RuntimeException {
|
||||
public JsonParseException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JsonParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public JsonParseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public JsonParseException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
protected JsonParseException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
|
@ -77,7 +77,7 @@ public class JsonUtils {
|
|||
try {
|
||||
return DEFAULT_JSON_MAPPER.writeValueAsString(source);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new JsonParseException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class JsonUtils {
|
|||
try {
|
||||
return DEFAULT_JSON_MAPPER.readValue(json, toValueType);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new JsonParseException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue