wolfboys commented on code in PR #1836:
URL: 
https://github.com/apache/incubator-streampark/pull/1836#discussion_r995336596


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/enums/Status.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.streampark.console.core.enums;
+
+import java.util.Optional;
+
+/**
+ * status enum
+ */
+public enum Status {
+
+    SUCCESS(0, "success"),
+
+    INTERNAL_SERVER_ERROR_ARGS(10000, "Internal Server Error: {0}"),
+    USER_CURRENTLY_LOCKED(10002, "user is currently locked"),
+    USER_NAME_EXIST(10003, "user name already exists"),
+    USER_NAME_NULL(10004, "user name is null"),
+    USER_NOT_EXIST(10005, "user {0} not exists"),
+    NOT_SUPPORTED_REQUEST_METHOD(10006, "not supported request method 
exception: {0}"),
+    API_FAIL(10007, "API Invoke exception:{0}"),
+    REQUEST_PARAMS_NOT_VALID_ERROR(10007, "request parameter {0} is not 
valid"),
+    READ_BUILD_LOG_EXECPTION(10008, "read build log exception: {0}"),

Review Comment:
   unify the definition of several of the most common exceptions, very good, 
but there are many purely business exceptions, the definition out of the 
unreasonable. Too much information about business exceptions, can not be 
predetermined in advance



##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/handler/GlobalExceptionHandler.java:
##########
@@ -51,21 +54,21 @@ public class GlobalExceptionHandler {
     @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
     public RestResponse handleException(Exception e) {
         log.info("Internal server error:", e);
-        return RestResponse.fail("internal server error: " + e.getMessage(), 
ResponseCode.CODE_FAIL);
+        return RestResponse.fail(INTERNAL_SERVER_ERROR_ARGS, e.getMessage());

Review Comment:
   `RestResponse.fail(...)` In many cases, a very specific business exception 
is returned, in short, the exception information of this error cannot be 
extracted uniformly and predetermined in advance.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to