You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "sk0x50 (via GitHub)" <gi...@apache.org> on 2023/06/01 07:28:04 UTC

[GitHub] [ignite-3] sk0x50 commented on a diff in pull request #2107: IGNITE-19534 Fixed error code duplication in the error message

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


##########
modules/api/src/test/java/org/apache/ignite/lang/IgniteExceptionTest.java:
##########
@@ -32,34 +32,89 @@
  */
 public class IgniteExceptionTest {
     @Test
-    public void testWrapUncheckedException() {
-        var originalEx = new CustomTestException(UUID.randomUUID(), Table.TABLE_NOT_FOUND_ERR, "Error foo bar", null);
+    public void testWrapPublicUncheckedException() {
+        var originalMessage = "Error foo bar";
+        var originalTraceId = UUID.randomUUID();
+        var expectedFullMessage = CustomTestException.class.getName() + ": "
+                + errorMessage(originalTraceId, Table.TABLE_NOT_FOUND_ERR, originalMessage);
+
+        var originalEx = new CustomTestException(originalTraceId, Table.TABLE_NOT_FOUND_ERR, originalMessage, null);
         var wrappedEx = new CompletionException(originalEx);
         var res = IgniteException.wrap(wrappedEx);
 
-        assertThat(res.getMessage(), containsString("Error foo bar"));
         assertEquals(originalEx.traceId(), res.traceId());
         assertEquals(originalEx.code(), res.code());
         assertEquals(originalEx.getClass(), res.getClass());
         assertSame(originalEx, res.getCause());
+        assertEquals(originalMessage, res.getMessage());
+        assertEquals(expectedFullMessage, res.toString());
     }
 
     @Test
-    public void testWrapCheckedException() {
-        var originalEx = new IgniteCheckedException(Table.COLUMN_ALREADY_EXISTS_ERR, "Msg.");
+    public void testWrapPublicCheckedException() {
+        var originalMessage = "Msg";
+        var originalTraceId = UUID.randomUUID();
+        var expectedFullMessage = IgniteException.class.getName() + ": "
+                + errorMessage(originalTraceId, Table.COLUMN_ALREADY_EXISTS_ERR, originalMessage);
+
+        var originalEx = new IgniteCheckedException(originalTraceId, Table.COLUMN_ALREADY_EXISTS_ERR, originalMessage);
         var wrappedEx = new CompletionException(originalEx);
         var res = IgniteException.wrap(wrappedEx);
 
-        assertThat(res.getMessage(), containsString("Msg."));
         assertEquals(originalEx.traceId(), res.traceId());
         assertEquals(originalEx.code(), res.code());
         assertSame(originalEx, res.getCause());
+        assertEquals(originalMessage, res.getMessage());
+        assertEquals(expectedFullMessage, res.toString());
+    }
+
+    @Test
+    public void testWrapInternalException() {
+        var originalMessage = "Unexpected error.";
+        var originalTraceId = UUID.randomUUID();
+
+        var originalEx = new IgniteInternalException(originalTraceId, Common.INTERNAL_ERR, originalMessage);
+        var wrappedEx = new CompletionException(originalEx);
+        var res = IgniteException.wrap(wrappedEx);

Review Comment:
   Ok. this makes sense to me. I will change



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org