From 1398231d259107854c7dc9400f365263a2ca895e Mon Sep 17 00:00:00 2001
From: Daniel Plagge <plagge@cs.uni-duesseldorf.de>
Date: Tue, 12 Feb 2013 22:42:26 +0100
Subject: [PATCH] Converting RuntimeExceptions to TranslationFailedExceptions,
 because the latter failed silently on export to classical ProB

---
 .../eventb/translator/TranslatorFactory.java  | 33 +++++++++++--------
 1 file changed, 19 insertions(+), 14 deletions(-)

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 8f7d0c95..25acab2f 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);
 		}
 	}
 
-- 
GitLab