Skip to content
Snippets Groups Projects
Commit 6c878b6c authored by Irina Muntean's avatar Irina Muntean
Browse files

Added comments.

Issue-Ref: 4168
Issue-Url: af3#4168



Signed-off-by: default avatarIrina Muntean <muntean@fortiss.org>
parent a201c64c
No related branches found
No related tags found
1 merge request!159Add caught exception to list and throw new exception
...@@ -23,7 +23,7 @@ import java.util.List; ...@@ -23,7 +23,7 @@ import java.util.List;
*/ */
public class AllChainTransformationsFailedException extends ChainTransformationFailedException { 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; private final List<ChainTransformationFailedException> exceptionList;
/** Constructor. */ /** Constructor. */
...@@ -36,20 +36,27 @@ public class AllChainTransformationsFailedException extends ChainTransformationF ...@@ -36,20 +36,27 @@ public class AllChainTransformationsFailedException extends ChainTransformationF
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getMessage() { public String getMessage() {
// Initial number of tabs = 0.
return getMessage(0); return getMessage(0);
} }
/** /**
* @param i * Recursive method iterating through the caught TransformationFailedExceptions of one provider
* @return * 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) { private String getMessage(int counter) {
String msg = ""; String msg = "";
String tabs = addTabs(counter);
for(TransformationFailedException ctfe : this.exceptionList) { for(TransformationFailedException ctfe : this.exceptionList) {
String tabs = addTabs(counter);
msg += tabs + "Failed Provider:\n"; msg += tabs + "Failed Provider:\n";
msg += tabs + ctfe.getFailedProvider().getClass().getSimpleName() + "\n"; msg += tabs + ctfe.getFailedProvider().getClass().getSimpleName() + "\n";
// Here, the cause is either a ChainTransformationsFailedException or an
// AllChainTransformationsFailedException.
TransformationFailedException cause = (TransformationFailedException)ctfe.getCause(); TransformationFailedException cause = (TransformationFailedException)ctfe.getCause();
if(cause != null) { if(cause != null) {
msg += tabs + "Cause:\n"; msg += tabs + "Cause:\n";
......
...@@ -23,8 +23,8 @@ import java.util.List; ...@@ -23,8 +23,8 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.data.ITransformationContext; import org.fortiss.tooling.kernel.extension.data.ITransformationContext;
import org.fortiss.tooling.kernel.extension.data.TransformationProviderChain; 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.AllChainTransformationsFailedException;
import org.fortiss.tooling.kernel.extension.exception.ChainTransformationFailedException;
import org.fortiss.tooling.kernel.service.ITransformationService; import org.fortiss.tooling.kernel.service.ITransformationService;
/** /**
...@@ -52,6 +52,7 @@ public final class TransformationUtils { ...@@ -52,6 +52,7 @@ public final class TransformationUtils {
public static <T extends Object> T createTransformedObjectFor(final EObject sourceElement, public static <T extends Object> T createTransformedObjectFor(final EObject sourceElement,
final Class<T> targetClass, ITransformationContext context) final Class<T> targetClass, ITransformationContext context)
throws ChainTransformationFailedException { throws ChainTransformationFailedException {
// Stores the exceptions of the providers.
List<TransformationProviderChain> chainList = ITransformationService.getInstance() List<TransformationProviderChain> chainList = ITransformationService.getInstance()
.getTransformationProviderChain(sourceElement.getClass(), targetClass, context); .getTransformationProviderChain(sourceElement.getClass(), targetClass, context);
List<ChainTransformationFailedException> exceptionList = new ArrayList<>(); List<ChainTransformationFailedException> exceptionList = new ArrayList<>();
...@@ -69,7 +70,6 @@ public final class TransformationUtils { ...@@ -69,7 +70,6 @@ public final class TransformationUtils {
" ensure correct operation of all involved TransformationProviders."); " ensure correct operation of all involved TransformationProviders.");
return executableObject; return executableObject;
} catch(ChainTransformationFailedException ctfe) { } catch(ChainTransformationFailedException ctfe) {
// fall through
exceptionList.add(ctfe); exceptionList.add(ctfe);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment