diff --git a/de.prob.core/src/de/prob/eventb/translator/TranslatorFactory.java b/de.prob.core/src/de/prob/eventb/translator/TranslatorFactory.java index 8f7d0c95826235ae17633361922c7237640c9396..25acab2f8f4d3c5f0dbe43e77784988ff2786a71 100644 --- a/de.prob.core/src/de/prob/eventb/translator/TranslatorFactory.java +++ b/de.prob.core/src/de/prob/eventb/translator/TranslatorFactory.java @@ -33,20 +33,25 @@ public class TranslatorFactory { */ public static void translate(final IEventBRoot root, final IPrologTermOutput pto) throws TranslationFailedException { - - if (root instanceof IMachineRoot) { - final ISCMachineRoot scRoot = ((IMachineRoot) root) - .getSCMachineRoot(); - EventBMachineTranslator.create(scRoot, pto); - - } else if (root instanceof IContextRoot) { - final ISCContextRoot scRoot = ((IContextRoot) root) - .getSCContextRoot(); - EventBContextTranslator.create(scRoot, pto); - } else { - throw new TranslationFailedException(root.getComponentName(), - "Cannot translate anything else than IMachineRoot or IContextRoot. Type was: " - + root.getClass()); + final String componentName = root.getComponentName(); + try { + if (root instanceof IMachineRoot) { + final ISCMachineRoot scRoot = ((IMachineRoot) root) + .getSCMachineRoot(); + EventBMachineTranslator.create(scRoot, pto); + + } else if (root instanceof IContextRoot) { + final ISCContextRoot scRoot = ((IContextRoot) root) + .getSCContextRoot(); + EventBContextTranslator.create(scRoot, pto); + } else { + throw new TranslationFailedException(componentName, + "Cannot translate anything else than IMachineRoot or IContextRoot. Type was: " + + root.getClass()); + } + } catch (RuntimeException e) { + throw new TranslationFailedException(componentName, + "A runtime exception occurred: " + e.getMessage(), e); } }