Commit 96d04faf by 张乐 Committed by GitHub

Merge pull request #381 from nobodyiam/global-exception-handler-fix

fix the potential error when handling exceptions
parents 5219b5c6 eaa877cf
......@@ -86,12 +86,20 @@ public class GlobalDefaultExceptionHandler {
Map<String, Object> errorAttributes = new HashMap<>();
boolean errorHandled = false;
//如果是admin server引起的异常,则显示内部的异常信息
if (ex instanceof HttpStatusCodeException) {
try {
//try to extract the original error info if it is thrown from apollo programs, e.g. admin service
errorAttributes = gson.fromJson(((HttpStatusCodeException) ex).getResponseBodyAsString(), mapType);
status = ((HttpStatusCodeException) ex).getStatusCode();
} else {
errorHandled = true;
} catch (Throwable th) {
//ignore
}
}
if (!errorHandled) {
errorAttributes.put("status", status.value());
errorAttributes.put("message", message);
errorAttributes.put("timestamp",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment