ygerzhedovich commented on code in PR #2613:
URL: https://github.com/apache/ignite-3/pull/2613#discussion_r1356119126
##########
modules/core/src/main/java/org/apache/ignite/internal/lang/IgniteExceptionMapperUtil.java:
##########
@@ -87,32 +87,40 @@ public static Throwable mapToPublicException(Throwable
origin) {
if (origin instanceof AssertionError) {
return new IgniteException(INTERNAL_ERR, origin);
}
-
return origin;
}
- IgniteExceptionMapper<? extends Exception, ? extends Exception> m =
EXCEPTION_CONVERTERS.get(origin.getClass());
+ Throwable res;
+
+ // Try to find appropriate mapper, moving from original class to
supper-classes step by step.
+ Class exceptionClass = origin.getClass();
+ IgniteExceptionMapper<? extends Exception, ? extends Exception> m;
+ while ((m = EXCEPTION_CONVERTERS.get(exceptionClass)) == null &&
exceptionClass != Throwable.class) {
+ exceptionClass = exceptionClass.getSuperclass();
+ }
+
if (m != null) {
- Exception mapped = map(m, origin);
+ res = map(m, origin);
- assert mapped instanceof IgniteException || mapped instanceof
IgniteCheckedException :
- "Unexpected mapping of internal exception to a public one
[origin=" + origin + ", mapped=" + mapped + ']';
+ assert res instanceof IgniteException || res instanceof
IgniteCheckedException :
+ "Unexpected mapping of internal exception to a public one
[origin=" + origin + ", mapped=" + res + ']';
- return mapped;
+ } else {
+ res = origin;
}
- if (origin instanceof IgniteException || origin instanceof
IgniteCheckedException) {
-
- return origin;
+ if (res instanceof IgniteException || res instanceof
IgniteCheckedException) {
+ return res;
}
// There are no exception mappings for the given exception. This case
should be considered as internal error.
return new IgniteException(INTERNAL_ERR, origin);
+
Review Comment:
yep
##########
modules/core/src/test/java/org/apache/ignite/internal/lang/IgniteExceptionMapperUtilTest.java:
##########
@@ -203,5 +203,12 @@ public static class CustomNoMappingException extends
IgniteInternalException {
public CustomNoMappingException() {
super(INTERNAL_ERR, "Test internal exception [err=no mapping]");
}
+
+ /**
+ * Creates a new instance of CustomNoMappingException with given code.
+ */
+ public CustomNoMappingException(int code) {
Review Comment:
yep
--
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]