Commit cb7be89c by Nepxion

优化异常抛出

parent db9b63cd
...@@ -60,7 +60,9 @@ public class ConfigEndpoint implements MvcEndpoint { ...@@ -60,7 +60,9 @@ public class ConfigEndpoint implements MvcEndpoint {
public ResponseEntity<?> sendAsync(@RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) { public ResponseEntity<?> sendAsync(@RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled(); Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
if (!discoveryControlEnabled) { if (!discoveryControlEnabled) {
return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND); // return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Discovery control is disabled");
} }
try { try {
...@@ -82,7 +84,7 @@ public class ConfigEndpoint implements MvcEndpoint { ...@@ -82,7 +84,7 @@ public class ConfigEndpoint implements MvcEndpoint {
public ResponseEntity<?> sendSync(@RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) { public ResponseEntity<?> sendSync(@RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled(); Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
if (!discoveryControlEnabled) { if (!discoveryControlEnabled) {
return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Discovery control is disabled");
} }
try { try {
...@@ -120,7 +122,7 @@ public class ConfigEndpoint implements MvcEndpoint { ...@@ -120,7 +122,7 @@ public class ConfigEndpoint implements MvcEndpoint {
message = "An internal error occurred while processing your request\n" + message; message = "An internal error occurred while processing your request\n" + message;
return new ResponseEntity<String>(message, HttpStatus.INTERNAL_SERVER_ERROR); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(message);
} }
@Override @Override
......
...@@ -14,7 +14,6 @@ import io.swagger.annotations.ApiOperation; ...@@ -14,7 +14,6 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -56,7 +55,7 @@ public class VersionEndpoint implements MvcEndpoint { ...@@ -56,7 +55,7 @@ public class VersionEndpoint implements MvcEndpoint {
public ResponseEntity<?> send(@RequestBody @ApiParam(value = "版本号", required = true) String version) { public ResponseEntity<?> send(@RequestBody @ApiParam(value = "版本号", required = true) String version) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled(); Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
if (!discoveryControlEnabled) { if (!discoveryControlEnabled) {
return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Discovery control is disabled");
} }
pluginEventWapper.fireVersionChanged(new VersionChangedEvent(VersionChangedEvent.EventType.VERSION_UPDATE, version), true); pluginEventWapper.fireVersionChanged(new VersionChangedEvent(VersionChangedEvent.EventType.VERSION_UPDATE, version), true);
...@@ -71,7 +70,7 @@ public class VersionEndpoint implements MvcEndpoint { ...@@ -71,7 +70,7 @@ public class VersionEndpoint implements MvcEndpoint {
public ResponseEntity<?> clear() { public ResponseEntity<?> clear() {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled(); Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
if (!discoveryControlEnabled) { if (!discoveryControlEnabled) {
return new ResponseEntity<>(Collections.singletonMap("Message", "Discovery control is disabled"), HttpStatus.NOT_FOUND); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Discovery control is disabled");
} }
pluginEventWapper.fireVersionChanged(new VersionChangedEvent(VersionChangedEvent.EventType.VERSION_CLEAR), true); pluginEventWapper.fireVersionChanged(new VersionChangedEvent(VersionChangedEvent.EventType.VERSION_CLEAR), true);
......
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