From 6c878b6cd8f8fd616a5a412af4e93eec48682f35 Mon Sep 17 00:00:00 2001 From: Irina Muntean <muntean@fortiss.org> Date: Fri, 3 Dec 2021 16:04:20 +0100 Subject: [PATCH] Added comments. Issue-Ref: 4168 Issue-Url: https://git.fortiss.org/af3/af3/-/issues/4168 Signed-off-by: Irina Muntean <muntean@fortiss.org> --- .../AllChainTransformationsFailedException.java | 15 +++++++++++---- .../tooling/kernel/utils/TransformationUtils.java | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/exception/AllChainTransformationsFailedException.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/exception/AllChainTransformationsFailedException.java index c7e27e3b9..c47cbc3c0 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/exception/AllChainTransformationsFailedException.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/exception/AllChainTransformationsFailedException.java @@ -23,7 +23,7 @@ import java.util.List; */ public class AllChainTransformationsFailedException extends ChainTransformationFailedException { - /** Stores a reference to the transformation provider chain. */ + /** Stores the caught ChainTransformationFailedExceptions thrown by a provider. */ private final List<ChainTransformationFailedException> exceptionList; /** Constructor. */ @@ -36,20 +36,27 @@ public class AllChainTransformationsFailedException extends ChainTransformationF /** {@inheritDoc} */ @Override public String getMessage() { + // Initial number of tabs = 0. return getMessage(0); } /** - * @param i - * @return + * Recursive method iterating through the caught TransformationFailedExceptions of one provider + * backtracking to the source of the errors by examining the cause of each iterated object. + * + * @param counter + * number of tabs used in the current recursive step. + * @return Message expressing the failed provider + cause. */ private String getMessage(int counter) { String msg = ""; + String tabs = addTabs(counter); for(TransformationFailedException ctfe : this.exceptionList) { - String tabs = addTabs(counter); msg += tabs + "Failed Provider:\n"; msg += tabs + ctfe.getFailedProvider().getClass().getSimpleName() + "\n"; + // Here, the cause is either a ChainTransformationsFailedException or an + // AllChainTransformationsFailedException. TransformationFailedException cause = (TransformationFailedException)ctfe.getCause(); if(cause != null) { msg += tabs + "Cause:\n"; diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/TransformationUtils.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/TransformationUtils.java index 4ee95df16..169a2143f 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/TransformationUtils.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/TransformationUtils.java @@ -23,8 +23,8 @@ import java.util.List; import org.eclipse.emf.ecore.EObject; import org.fortiss.tooling.kernel.extension.data.ITransformationContext; import org.fortiss.tooling.kernel.extension.data.TransformationProviderChain; -import org.fortiss.tooling.kernel.extension.exception.ChainTransformationFailedException; import org.fortiss.tooling.kernel.extension.exception.AllChainTransformationsFailedException; +import org.fortiss.tooling.kernel.extension.exception.ChainTransformationFailedException; import org.fortiss.tooling.kernel.service.ITransformationService; /** @@ -52,6 +52,7 @@ public final class TransformationUtils { public static <T extends Object> T createTransformedObjectFor(final EObject sourceElement, final Class<T> targetClass, ITransformationContext context) throws ChainTransformationFailedException { + // Stores the exceptions of the providers. List<TransformationProviderChain> chainList = ITransformationService.getInstance() .getTransformationProviderChain(sourceElement.getClass(), targetClass, context); List<ChainTransformationFailedException> exceptionList = new ArrayList<>(); @@ -69,7 +70,6 @@ public final class TransformationUtils { " ensure correct operation of all involved TransformationProviders."); return executableObject; } catch(ChainTransformationFailedException ctfe) { - // fall through exceptionList.add(ctfe); } } -- GitLab