korlov42 commented on code in PR #4991:
URL: https://github.com/apache/ignite-3/pull/4991#discussion_r1905325066
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroup.java:
##########
@@ -125,62 +129,14 @@ public static String errorMessage(UUID traceId, int code,
String message) {
* @param message Original message.
* @return New error message with predefined prefix.
*/
- public static String errorMessage(UUID traceId, String groupName, int
code, String message) {
- return ERR_PREFIX + groupName + '-' +
Short.toUnsignedInt(extractErrorCode(code)) + " TraceId:" + traceId
+ public static String errorMessage(String errorPrefix, UUID traceId, String
groupName, int code, String message) {
Review Comment:
first, we need to update javadoc. Second, I would propose to do this method
package private or even private. The reason is its contract: it accepts
`errorPrefix`, `groupName`, and full error `code`, which must correspond to
each other
##########
modules/api/src/main/java/org/apache/ignite/lang/ErrorGroups.java:
##########
@@ -73,13 +104,36 @@ public static synchronized ErrorGroup registerGroup(String
groupName, short grou
}
}
- ErrorGroup newGroup = new ErrorGroup(grpName, groupCode);
+ if (REGISTERED_ERROR_PREFIXES.add(errorPrefix)) {
+ String errorPrefixes = String.join("|", REGISTERED_ERROR_PREFIXES);
+ String pattern =
EXCEPTION_MESSAGE_STRING_PATTERN.replace(PLACEHOLDER, errorPrefixes);
+ EXCEPTION_MESSAGE_PATTERN = Pattern.compile(pattern, DOTALL);
Review Comment:
do we really need to recompile pattern every time? I would prefer to go with
more simple pattern, and do post validation like
`REGISTERED_ERROR_PREFIXES.contains(prefix)` if this really necessary
--
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]