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;
*/
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";
......
......@@ -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);
}
}
......
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