sk0x50 commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1916425982


##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroup.java:
##########
@@ -17,46 +17,49 @@
 
 package org.apache.ignite.lang;
 
-import static java.util.regex.Pattern.DOTALL;
 import static org.apache.ignite.lang.ErrorGroups.errorGroupByCode;
 
 import java.util.HashSet;
 import java.util.Set;
 import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * This class represents a concept of error group. Error group defines a 
collection of errors that belong to a single semantic component.
  * Each group can be identified by a name and an integer number that both must 
be unique across all error groups.
  */
 public class ErrorGroup {
-    /** Additional prefix that is used in a human-readable format of ignite 
errors. */
-    public static final String ERR_PREFIX = "IGN-";
-
-    /** Error message pattern. */
-    private static final Pattern EXCEPTION_MESSAGE_PATTERN =
-            
Pattern.compile("(.*)(IGN)-([A-Z]+)-(\\d+)\\s(TraceId:)([a-f0-9]{8}(?:-[a-f0-9]{4}){4}[a-f0-9]{8})(\\s?)(.*)",
 DOTALL);
-
     /** Group name. */
     private final String groupName;
 
     /** Group code. */
     private final short groupCode;
 
+    /** Additional prefix that is used in a human-readable format of error 
messages. */
+    private final String errorPrefix;

Review Comment:
   Hmm, I'm a little confused by the name. Perhaps, it would be nice to change 
to `groupNamePrefix`, or `vendorSpecificPrefix` etc. What do you think?



##########
modules/core/src/main/java/org/apache/ignite/internal/lang/ErrorGroupHelper.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.ignite.internal.lang;
+
+import static org.apache.ignite.lang.ErrorGroup.extractErrorCode;
+
+import java.util.UUID;
+
+/**
+ * The class contains just single method which is fully copy of {@link 
ErrorGroup#errorMessage(String, UUID, String, int, String)} which is
+ * placed in public API and shouldn't be visible to outside. It required just 
to hide our internal things.
+ */
+class ErrorGroupHelper {
+
+    /**
+     * Creates a new error message with predefined prefix. Code of the method 
should be identical to {@code ErrorGroup.errorMessage}. We
+     * have code duplication just to remove from public api our dirty part.
+     *
+     * @param errorPrefix Prefix for the error.
+     * @param traceId Unique identifier of this exception.
+     * @param groupName Group name.
+     * @param code Full error code.
+     * @param message Original message.
+     * @return New error message with predefined prefix.
+     */
+    static String errorMessage(String errorPrefix, UUID traceId, String 
groupName, int code, String message) {

Review Comment:
   Honestly, I don't like this idea. I mean creating a new class with 
duplicating code looks odd to me.



##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroups.java:
##########
@@ -17,16 +17,33 @@
 
 package org.apache.ignite.lang;
 
+import static java.util.regex.Pattern.DOTALL;
+
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Locale;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import org.apache.ignite.error.code.annotations.ErrorCodeGroup;
+import org.jetbrains.annotations.Nullable;
 
 /**
  * Defines error groups and its errors.
  */
 @SuppressWarnings("PublicInnerClass")
 public class ErrorGroups {
+    /** Additional prefix that is used in a human-readable format of ignite 
errors. */
+    public static final String IGNITE_ERR_PREFIX = "IGN";

Review Comment:
   Perhaps, the following code should be updated as well 
https://github.com/apache/ignite-3/blob/6b4a633dcce8360741da90f6dc42a73f574defca/modules/platforms/dotnet/Apache.Ignite/ErrorGroups.cs#L39



-- 
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