You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2023/07/21 16:41:48 UTC

[plc4x] branch develop updated: chore: Cleaned up what was causing sonar to complain about using generic exceptions.

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4c4155ecdb chore: Cleaned up what was causing sonar to complain about using generic exceptions.
4c4155ecdb is described below

commit 4c4155ecdbe0bcc9690b630dc161dd98e6bd1337
Author: Christofer Dutz <cd...@apache.org>
AuthorDate: Fri Jul 21 18:41:39 2023 +0200

    chore: Cleaned up what was causing sonar to complain about using generic exceptions.
---
 .../plc4x/language/c/CLanguageTemplateHelper.java  | 36 +++++------
 .../language/cs/CsLanguageTemplateHelper.java      | 72 ++++++++++-----------
 .../language/go/GoLanguageTemplateHelper.java      | 74 +++++++++++-----------
 .../language/java/JavaLanguageTemplateHelper.java  | 10 +--
 .../python/PythonLanguageTemplateHelper.java       | 72 ++++++++++-----------
 5 files changed, 132 insertions(+), 132 deletions(-)

diff --git a/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java b/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
index 21e068875f..0b70726404 100644
--- a/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
+++ b/code-generation/language-c/src/main/java/org/apache/plc4x/language/c/CLanguageTemplateHelper.java
@@ -221,7 +221,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
                     if (integerTypeReference.getSizeInBits() <= 64) {
                         return "uint64_t";
                     }
-                    throw new RuntimeException("Unsupported simple type");
+                    throw new FreemarkerException("Unsupported simple type");
                 }
                 case INT: {
                     IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
@@ -237,7 +237,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
                     if (integerTypeReference.getSizeInBits() <= 64) {
                         return "int64_t";
                     }
-                    throw new RuntimeException("Unsupported simple type");
+                    throw new FreemarkerException("Unsupported simple type");
                 }
                 case FLOAT:
                     FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
@@ -290,7 +290,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
                     if (integerTypeReference.getSizeInBits() <= 64) {
                         return "ulint";
                     }
-                    throw new RuntimeException("Unsupported simple type");
+                    throw new FreemarkerException("Unsupported simple type");
                 }
                 case INT: {
                     IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
@@ -306,7 +306,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
                     if (integerTypeReference.getSizeInBits() <= 64) {
                         return "lint";
                     }
-                    throw new RuntimeException("Unsupported simple type");
+                    throw new FreemarkerException("Unsupported simple type");
                 }
                 case FLOAT:
                     FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
@@ -491,7 +491,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
             case STRING: {
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
@@ -501,7 +501,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
             case VSTRING: {
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 // Here we need to use the serialized expression of the length instead.
@@ -562,7 +562,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
             case STRING: {
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
@@ -572,7 +572,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
             case VSTRING: {
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 // Here we need to use the serialized expression of the length instead.
@@ -895,7 +895,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
             // TODO: replace with map join
             final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
             if (!(encodingTerm instanceof StringLiteral)) {
-                throw new RuntimeException("Encoding must be a quoted string value");
+                throw new FreemarkerException("Encoding must be a quoted string value");
             }
             String encoding = ((StringLiteral) encodingTerm).getValue();
             return tracer + "\"" + encoding + "\"";
@@ -948,18 +948,18 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
 
     private String toCastVariableParseExpression(TypeDefinition baseType, Field field, VariableLiteral variableLiteral, List<Argument> parserArguments, Tracer tracer) {
         tracer = tracer.dive("CAST");
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A Cast expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A Cast expression needs arguments"));
         if (arguments.size() != 2) {
-            throw new RuntimeException("A CAST expression expects exactly two arguments.");
+            throw new FreemarkerException("A CAST expression expects exactly two arguments.");
         }
         VariableLiteral firstArgument = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a Variable literal"));
+            .orElseThrow(() -> new FreemarkerException("First argument should be a Variable literal"));
         StringLiteral typeLiteral = arguments.get(1).asLiteral()
-            .orElseThrow(() -> new RuntimeException("Second argument should be a String literal"))
+            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Second argument should be a String literal"));
+            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"));
 
         final TypeDefinition castType = getTypeDefinitions().get(typeLiteral.getValue());
         // If we're casting to a sub-type of a discriminated value, we got to cast to the parent
@@ -1084,7 +1084,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
                     }
                     final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                     if (!(encodingTerm instanceof StringLiteral)) {
-                        throw new RuntimeException("Encoding must be a quoted string value");
+                        throw new FreemarkerException("Encoding must be a quoted string value");
                     }
                     String encoding = ((StringLiteral) encodingTerm).getValue();
                     return tracer + "\"" + encoding + "\"";
@@ -1176,7 +1176,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
                                 }
                                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                                 if (!(encodingTerm instanceof StringLiteral)) {
-                                    throw new RuntimeException("Encoding must be a quoted string value");
+                                    throw new FreemarkerException("Encoding must be a quoted string value");
                                 }
                                 String encoding = ((StringLiteral) encodingTerm).getValue();
                                 sb.append("\"").append(encoding).append("\"");
@@ -1253,7 +1253,7 @@ public class CLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelpe
                             }
                             final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                             if (!(encodingTerm instanceof StringLiteral)) {
-                                throw new RuntimeException("Encoding must be a quoted string value");
+                                throw new FreemarkerException("Encoding must be a quoted string value");
                             }
                             String encoding = ((StringLiteral) encodingTerm).getValue();
                             sb.append("\"").append(encoding).append("\"");
diff --git a/code-generation/language-cs/src/main/java/org/apache/plc4x/language/cs/CsLanguageTemplateHelper.java b/code-generation/language-cs/src/main/java/org/apache/plc4x/language/cs/CsLanguageTemplateHelper.java
index 1bdb5d57bb..9704012cf1 100644
--- a/code-generation/language-cs/src/main/java/org/apache/plc4x/language/cs/CsLanguageTemplateHelper.java
+++ b/code-generation/language-cs/src/main/java/org/apache/plc4x/language/cs/CsLanguageTemplateHelper.java
@@ -111,7 +111,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (unsignedIntegerTypeReference.getSizeInBits() <= 64) {
                     return "ulong";
                 }
-                throw new RuntimeException("Unsupported simple type");
+                throw new FreemarkerException("Unsupported simple type");
             case INT:
                 IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
                 if (integerTypeReference.getSizeInBits() <= 8) {
@@ -126,7 +126,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (integerTypeReference.getSizeInBits() <= 64) {
                     return "long";
                 }
-                throw new RuntimeException("Unsupported simple type");
+                throw new FreemarkerException("Unsupported simple type");
             case FLOAT:
             case UFLOAT:
                 FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
@@ -137,7 +137,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (sizeInBits <= 64) {
                     return "double";
                 }
-                throw new RuntimeException("Unsupported simple type");
+                throw new FreemarkerException("Unsupported simple type");
             case STRING:
             case VSTRING:
                 return "string";
@@ -149,7 +149,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 return "datetime2";
 
         }
-        throw new RuntimeException("Unsupported simple type");
+        throw new FreemarkerException("Unsupported simple type");
     }
 
     public String getPlcValueTypeForTypeReference(TypeReference typeReference) {
@@ -176,7 +176,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (sizeInBits <= 64) {
                     return "PlcULINT";
                 }
-                throw new RuntimeException("Unsupported UINT with bit length " + sizeInBits);
+                throw new FreemarkerException("Unsupported UINT with bit length " + sizeInBits);
             case INT:
                 if (sizeInBits <= 8) {
                     return "PlcSINT";
@@ -190,7 +190,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (sizeInBits <= 64) {
                     return "PlcLINT";
                 }
-                throw new RuntimeException("Unsupported INT with bit length " + sizeInBits);
+                throw new FreemarkerException("Unsupported INT with bit length " + sizeInBits);
             case FLOAT:
             case UFLOAT:
                 if (sizeInBits <= 32) {
@@ -199,7 +199,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (sizeInBits <= 64) {
                     return "PlcLREAL";
                 }
-                throw new RuntimeException("Unsupported REAL with bit length " + sizeInBits);
+                throw new FreemarkerException("Unsupported REAL with bit length " + sizeInBits);
             case STRING:
             case VSTRING:
                 return "PlcSTRING";
@@ -208,7 +208,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
             case DATETIME:
                 return "PlcTIME";
         }
-        throw new RuntimeException("Unsupported simple type");
+        throw new FreemarkerException("Unsupported simple type");
     }
 
     @Override
@@ -306,7 +306,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 } else if (unsignedIntegerTypeReference.getSizeInBits() <= 64) {
                     unsignedIntegerType = "Ulong";
                 } else {
-                    throw new RuntimeException("Unsupported type");
+                    throw new FreemarkerException("Unsupported type");
                 }
                 return "readBuffer.Read" + unsignedIntegerType + "(\"" + logicalName + "\", " + simpleTypeReference.getSizeInBits() + ")";
             case INT:
@@ -320,7 +320,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 } else if (simpleTypeReference.getSizeInBits() <= 64) {
                     integerType = "Long";
                 } else {
-                    throw new RuntimeException("Unsupported type");
+                    throw new FreemarkerException("Unsupported type");
                 }
                 return "readBuffer.Read" + integerType + "(\"" + logicalName + "\", " + simpleTypeReference.getSizeInBits() + ")";
             case FLOAT:
@@ -331,7 +331,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 String stringType = "String";
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
@@ -520,7 +520,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (unsignedIntegerTypeReference.getSizeInBits() <= 64) {
                     return "writeBuffer.WriteUlong(\"" + logicalName + "\", " + unsignedIntegerTypeReference.getSizeInBits() + ", (ulong) " + fieldName + writerArgsString + ")";
                 }
-                throw new RuntimeException("Unsupported uint type");
+                throw new FreemarkerException("Unsupported uint type");
             case INT:
                 IntegerTypeReference integerTypeReference = (IntegerTypeReference) simpleTypeReference;
                 if (integerTypeReference.getSizeInBits() <= 8) {
@@ -535,7 +535,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 if (integerTypeReference.getSizeInBits() <= 64) {
                     return "writeBuffer.WriteLong(\"" + logicalName + "\", " + integerTypeReference.getSizeInBits() + ", (long) " + fieldName + writerArgsString + ")";
                 }
-                throw new RuntimeException("Unsupported int type");
+                throw new FreemarkerException("Unsupported int type");
             case FLOAT:
             case UFLOAT:
                 FloatTypeReference floatTypeReference = (FloatTypeReference) simpleTypeReference;
@@ -544,13 +544,13 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 } else if (floatTypeReference.getSizeInBits() <= 64) {
                     return "writeBuffer.WriteDouble(\"" + logicalName + "\", " + floatTypeReference.getSizeInBits() + "," + fieldName + writerArgsString + ")";
                 } else {
-                    throw new RuntimeException("Unsupported float type");
+                    throw new FreemarkerException("Unsupported float type");
                 }
             case STRING:
             case VSTRING:
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
@@ -611,7 +611,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
         } else if (term instanceof TernaryTerm) {
             return toTernaryTermExpression(field, resultType, (TernaryTerm) term, variableExpressionGenerator, tracer);
         } else {
-            throw new RuntimeException("Unsupported Term type " + term.getClass().getName());
+            throw new FreemarkerException("Unsupported Term type " + term.getClass().getName());
         }
     }
 
@@ -627,7 +627,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
             tracer = tracer.dive("numeric literal instanceOf");
             final String numberString = ((NumericLiteral) literal).getNumber().toString();
             if (resultType.isIntegerTypeReference()) {
-                final IntegerTypeReference integerTypeReference = resultType.asIntegerTypeReference().orElseThrow(RuntimeException::new);
+                final IntegerTypeReference integerTypeReference = resultType.asIntegerTypeReference().orElseThrow(FreemarkerException::new);
                 if (integerTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.UINT && integerTypeReference.getSizeInBits() >= 32) {
                     tracer = tracer.dive("uint >= 32bit");
                     return tracer + numberString + "L";
@@ -636,7 +636,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                     return tracer + numberString + "L";
                 }
             } else if (resultType.isFloatTypeReference()) {
-                final FloatTypeReference floatTypeReference = resultType.asFloatTypeReference().orElseThrow(RuntimeException::new);
+                final FloatTypeReference floatTypeReference = resultType.asFloatTypeReference().orElseThrow(FreemarkerException::new);
                 if (floatTypeReference.getSizeInBits() <= 32) {
                     tracer = tracer.dive("float < 32bit");
                     return tracer + numberString + "F";
@@ -647,7 +647,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
             tracer = tracer.dive("hexadecimal literal instanceOf");
             final String hexString = ((HexadecimalLiteral) literal).getHexString();
             if (resultType.isIntegerTypeReference()) {
-                final IntegerTypeReference integerTypeReference = resultType.asIntegerTypeReference().orElseThrow(RuntimeException::new);
+                final IntegerTypeReference integerTypeReference = resultType.asIntegerTypeReference().orElseThrow(FreemarkerException::new);
                 if (integerTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.UINT && integerTypeReference.getSizeInBits() >= 32) {
                     tracer = tracer.dive("uint >= 32bit");
                     return tracer + hexString + "L";
@@ -670,14 +670,14 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
             if (getTypeDefinitions().get(variableLiteral.getName()) instanceof EnumTypeDefinition) {
                 tracer = tracer.dive("enum definition instanceOf");
                 VariableLiteral enumDefinitionChild = variableLiteral.getChild()
-                    .orElseThrow(() -> new RuntimeException("enum definitions should have childs"));
+                    .orElseThrow(() -> new FreemarkerException("enum definitions should have childs"));
                 return tracer + variableLiteral.getName() + "." + enumDefinitionChild.getName() +
                     enumDefinitionChild.getChild().map(child -> "." + toVariableExpressionRest(field, resultType, child)).orElse("");
             } else {
                 return tracer + variableExpressionGenerator.apply(variableLiteral);
             }
         } else {
-            throw new RuntimeException("Unsupported Literal type " + literal.getClass().getName());
+            throw new FreemarkerException("Unsupported Literal type " + literal.getClass().getName());
         }
     }
 
@@ -701,7 +701,7 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 tracer = tracer.dive("case ()");
                 return tracer + "(" + toExpression(field, resultType, a, variableExpressionGenerator) + ")";
             default:
-                throw new RuntimeException("Unsupported unary operation type " + unaryTerm.getOperation());
+                throw new FreemarkerException("Unsupported unary operation type " + unaryTerm.getOperation());
         }
     }
 
@@ -843,17 +843,17 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
 
     private String toCastVariableParseExpression(Field field, TypeReference resultType, VariableLiteral variableLiteral, List<Argument> parserArguments, Tracer tracer) {
         tracer = tracer.dive("CAST");
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A Cast expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A Cast expression needs arguments"));
         if (arguments.size() != 2) {
-            throw new RuntimeException("A CAST expression expects exactly two arguments.");
+            throw new FreemarkerException("A CAST expression expects exactly two arguments.");
         }
         VariableLiteral firstArgument = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a Variable literal"));
-        StringLiteral typeArgument = arguments.get(1).asLiteral().orElseThrow(() -> new RuntimeException("Second argument should be a String literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a Variable literal"));
+        StringLiteral typeArgument = arguments.get(1).asLiteral().orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Second argument should be a String literal"));
+            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"));
         String sb = "CAST" + "(" +
             toVariableParseExpression(field, ANY_TYPE_REFERENCE, firstArgument, parserArguments) +
             ", " +
@@ -868,18 +868,18 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
 
     private String toStaticCallParseExpression(Field field, TypeReference resultType, VariableLiteral variableLiteral, List<Argument> parserArguments, Tracer tracer) {
         tracer = tracer.dive("STATIC_CALL");
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A STATIC_CALL expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A STATIC_CALL expression needs arguments"));
         if (arguments.size() < 1) {
-            throw new RuntimeException("A STATIC_CALL expression expects at least one argument.");
+            throw new FreemarkerException("A STATIC_CALL expression expects at least one argument.");
         }
         // TODO: make it as static import with a emitImport so if a static call is present a "utils" package must be present in the import
         StringBuilder sb = new StringBuilder();
         sb.append(packageName()).append(".utils.StaticHelper.");
         // Get the class and method name
         String methodName = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
+            .orElseThrow(() -> new FreemarkerException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
             getValue();
         sb.append(methodName).append("(");
         for (int i = 1; i < arguments.size(); i++) {
@@ -1059,17 +1059,17 @@ public class CsLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
     private String toStaticCallSerializationExpression(Field field, TypeReference resultType, VariableLiteral variableLiteral, List<Argument> serialzerArguments, Tracer tracer) {
         tracer = tracer.dive("STATIC_CALL");
         StringBuilder sb = new StringBuilder();
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A STATIC_CALL expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A STATIC_CALL expression needs arguments"));
         if (arguments.size() < 1) {
-            throw new RuntimeException("A STATIC_CALL expression expects at least one argument.");
+            throw new FreemarkerException("A STATIC_CALL expression expects at least one argument.");
         }
         // TODO: make it as static import with a emitImport so if a static call is present a "utils" package must be present in the import
         sb.append(packageName()).append(".utils.StaticHelper.");
         // Get the class and method name
         String methodName = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
+            .orElseThrow(() -> new FreemarkerException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
             getValue();
         //methodName = methodName.substring(1, methodName.length() - 1);
         sb.append(methodName).append("(");
diff --git a/code-generation/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java b/code-generation/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
index 1e3b6038c6..8b7e5deba6 100644
--- a/code-generation/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
+++ b/code-generation/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
@@ -182,7 +182,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 emitRequiredImport("time");
                 return "time.Time";
             default:
-                throw new RuntimeException("Unsupported simple type");
+                throw new FreemarkerException("Unsupported simple type");
         }
     }
 
@@ -372,7 +372,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
             case STRING: {
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
@@ -382,7 +382,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 String lengthExpression = toExpression(field, null, vstringTypeReference.getLengthExpression(), null, null, false, false);
@@ -418,7 +418,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
         if (valueTerm instanceof StringLiteral) {
             return getWriteBufferWriteMethodCall(logicalName, simpleTypeReference, "\"" + ((StringLiteral) valueTerm).getValue() + "\"", field, writerArgs);
         }
-        throw new RuntimeException("Outputting " + valueTerm.toString() + " not implemented yet. Please continue defining other types in the GoLanguageHelper.getWriteBufferWriteMethodCall.");
+        throw new FreemarkerException("Outputting " + valueTerm.toString() + " not implemented yet. Please continue defining other types in the GoLanguageHelper.getWriteBufferWriteMethodCall.");
     }
 
     public String getWriteBufferWriteMethodCall(String logicalName, SimpleTypeReference simpleTypeReference, String fieldName, TypedField field, String... writerArgs) {
@@ -475,9 +475,9 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 StringTypeReference stringTypeReference = (StringTypeReference) simpleTypeReference;
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 String encoding = encodingTerm.asLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a literal"))
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a literal"))
                     .asStringLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a quoted string value")).getValue();
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a quoted string value")).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
                 return "writeBuffer.WriteString(\"" + logicalName + "\", uint32(" + length + "), \"" +
                     encoding + "\", " + fieldName + writerArgsString + ")";
@@ -486,9 +486,9 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 String encoding = encodingTerm.asLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a literal"))
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a literal"))
                     .asStringLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a quoted string value")).getValue();
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a quoted string value")).getValue();
                 String lengthExpression = toExpression(field, null, vstringTypeReference.getLengthExpression(), null, Collections.singletonList(new DefaultArgument("stringLength", new DefaultIntegerTypeReference(SimpleTypeReference.SimpleBaseType.INT, 32))), true, false);
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
                 return "writeBuffer.WriteString(\"" + logicalName + "\", uint32(" + lengthExpression + "), \"" +
@@ -606,7 +606,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
         } else if (term instanceof TernaryTerm) {
             return toTernaryTermExpression(field, fieldType, (TernaryTerm) term, parserArguments, serializerArguments, serialize, tracer);
         } else {
-            throw new RuntimeException("Unsupported Term type " + term.getClass().getName());
+            throw new FreemarkerException("Unsupported Term type " + term.getClass().getName());
         }
     }
 
@@ -631,7 +631,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
             }
             return tracer + inlineIf;
         } else {
-            throw new RuntimeException("Unsupported ternary operation type " + ternaryTerm.getOperation());
+            throw new FreemarkerException("Unsupported ternary operation type " + ternaryTerm.getOperation());
         }
     }
 
@@ -702,7 +702,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 tracer = tracer.dive("case ()");
                 return tracer + "(" + toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, false) + ")";
             default:
-                throw new RuntimeException("Unsupported unary operation type " + unaryTerm.getOperation());
+                throw new FreemarkerException("Unsupported unary operation type " + unaryTerm.getOperation());
         }
     }
 
@@ -740,7 +740,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
             }
             return tracer + toVariableExpression(field, fieldType, (VariableLiteral) term, parserArguments, serializerArguments, serialize, suppressPointerAccess);
         } else {
-            throw new RuntimeException("Unsupported Literal type " + term.getClass().getName());
+            throw new FreemarkerException("Unsupported Literal type " + term.getClass().getName());
         }
     }
 
@@ -854,7 +854,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                     tracer = tracer.dive("complex");
                     ComplexTypeDefinition complexTypeDefinition = (ComplexTypeDefinition) typeDefinition;
                     String childProperty = variableLiteral.getChild()
-                        .orElseThrow(() -> new RuntimeException("complex needs a child"))
+                        .orElseThrow(() -> new FreemarkerException("complex needs a child"))
                         .getName();
                     final Optional<Field> matchingDiscriminatorField = complexTypeDefinition.getFields().stream()
                         .filter(curField -> (curField instanceof DiscriminatorField) && ((DiscriminatorField) curField).getName().equals(childProperty))
@@ -871,7 +871,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                         variableAccess = "Get" + capitalize(variableLiteralName) + "()";
                     }
                     return tracer + (serialize ? "m.Get" + capitalize(variableLiteralName) + "()" : variableAccess) +
-                        "." + capitalize(variableLiteral.getChild().orElseThrow(() -> new RuntimeException("enum needs a child")).getName()) + "()";
+                        "." + capitalize(variableLiteral.getChild().orElseThrow(() -> new FreemarkerException("enum needs a child")).getName()) + "()";
                 }
             }
             // TODO: is this really meant to fall through?
@@ -955,7 +955,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
 
     private String toCeilVariableExpression(Field field, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("ceil");
-        Term va = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("CEIL needs at least one arg"))
+        Term va = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("CEIL needs at least one arg"))
             .stream().findFirst().orElseThrow(IllegalStateException::new);
         // The Ceil function expects 64 bit floating point values.
         TypeReference tr = new DefaultFloatTypeReference(SimpleTypeReference.SimpleBaseType.FLOAT, 64);
@@ -966,12 +966,12 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
     private String toArraySizeInBytesVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("array size in bytes");
         VariableLiteral va = variableLiteral.getArgs()
-            .orElseThrow(() -> new RuntimeException("ARRAY_SIZE_IN_BYTES needs at least one arg"))
+            .orElseThrow(() -> new FreemarkerException("ARRAY_SIZE_IN_BYTES needs at least one arg"))
             .stream().findFirst().orElseThrow(IllegalStateException::new)
             .asLiteral()
-            .orElseThrow(() -> new RuntimeException("ARRAY_SIZE_IN_BYTES needs a literal"))
+            .orElseThrow(() -> new FreemarkerException("ARRAY_SIZE_IN_BYTES needs a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("ARRAY_SIZE_IN_BYTES needs a variable literal"));
+            .orElseThrow(() -> new FreemarkerException("ARRAY_SIZE_IN_BYTES needs a variable literal"));
         // "io" and "m" are always available in every parser.
         boolean isSerializerArg = "readBuffer".equals(va.getName()) || "writeBuffer".equals(va.getName()) || "m".equals(va.getName()) || "element".equals(va.getName());
         if (!isSerializerArg && serializerArguments != null) {
@@ -994,12 +994,12 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
     private String toCountVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("count");
         VariableLiteral countLiteral = variableLiteral.getArgs()
-            .orElseThrow(() -> new RuntimeException("Count needs at least one arg"))
+            .orElseThrow(() -> new FreemarkerException("Count needs at least one arg"))
             .get(0)
             .asLiteral()
-            .orElseThrow(() -> new RuntimeException("Count needs a literal"))
+            .orElseThrow(() -> new FreemarkerException("Count needs a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("Count needs a variable literal"));
+            .orElseThrow(() -> new FreemarkerException("Count needs a variable literal"));
         return tracer + (typeReference instanceof SimpleTypeReference ? getCastExpressionForTypeReference(typeReference) : "") + "(len(" +
             toVariableExpression(field, typeReference, countLiteral, parserArguments, serializerArguments, serialize, suppressPointerAccess) +
             "))";
@@ -1008,12 +1008,12 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
     private String toStrLenVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("str-len");
         VariableLiteral countLiteral = variableLiteral.getArgs()
-            .orElseThrow(() -> new RuntimeException("Str-len needs at least one arg"))
+            .orElseThrow(() -> new FreemarkerException("Str-len needs at least one arg"))
             .get(0)
             .asLiteral()
-            .orElseThrow(() -> new RuntimeException("Str-len needs a literal"))
+            .orElseThrow(() -> new FreemarkerException("Str-len needs a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("Str-len needs a variable literal"));
+            .orElseThrow(() -> new FreemarkerException("Str-len needs a variable literal"));
         return tracer + (typeReference instanceof SimpleTypeReference ? getCastExpressionForTypeReference(typeReference) : "") + "(len(" +
             toVariableExpression(field, typeReference, countLiteral, parserArguments, serializerArguments, serialize, suppressPointerAccess) +
             "))";
@@ -1022,15 +1022,15 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
     private String toStaticCallVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("STATIC_CALL");
         StringBuilder sb = new StringBuilder();
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A STATIC_CALL expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A STATIC_CALL expression needs arguments"));
         if (arguments.size() < 1) {
-            throw new RuntimeException("A STATIC_CALL expression expects at least one argument.");
+            throw new FreemarkerException("A STATIC_CALL expression expects at least one argument.");
         }
         // Get the class and method name
         String staticCall = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
+            .orElseThrow(() -> new FreemarkerException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
             getValue();
         sb.append(capitalize(staticCall)).append("(").append("ctx, ");
         for (int i = 1; i < arguments.size(); i++) {
@@ -1078,7 +1078,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                         case "encoding":
                             final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                             if (!(encodingTerm instanceof StringLiteral)) {
-                                throw new RuntimeException("Encoding must be a quoted string value");
+                                throw new FreemarkerException("Encoding must be a quoted string value");
                             }
                             String encoding = ((StringLiteral) encodingTerm).getValue();
                             sb.append("\"").append(encoding).append("\"");
@@ -1100,7 +1100,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
                 tracer = tracer.dive("BinaryTerm");
                 sb.append(toBinaryTermExpression(field, typeReference, (BinaryTerm) arg, parserArguments, serializerArguments, serialize, tracer));
             } else {
-                throw new RuntimeException(arg.getClass().getName());
+                throw new FreemarkerException(arg.getClass().getName());
             }
         }
         sb.append(")");
@@ -1109,18 +1109,18 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
 
     private String toCastVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("CAST");
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A Cast expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A Cast expression needs arguments"));
         if (arguments.size() != 2) {
-            throw new RuntimeException("A CAST expression expects exactly two arguments.");
+            throw new FreemarkerException("A CAST expression expects exactly two arguments.");
         }
         VariableLiteral firstArgument = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a Variable literal"));
+            .orElseThrow(() -> new FreemarkerException("First argument should be a Variable literal"));
         StringLiteral typeLiteral = arguments.get(1).asLiteral()
-            .orElseThrow(() -> new RuntimeException("Second argument should be a String literal"))
+            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Second argument should be a String literal"));
+            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"));
         final TypeDefinition typeDefinition = getTypeDefinitions().get(typeLiteral.getValue());
         StringBuilder sb = new StringBuilder();
         if (typeDefinition.isComplexTypeDefinition()) {
@@ -1146,7 +1146,7 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp
 
     private String toEnumVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("enum");
-        VariableLiteral child = variableLiteral.getChild().orElseThrow(() -> new RuntimeException("Enum should have a child"));
+        VariableLiteral child = variableLiteral.getChild().orElseThrow(() -> new FreemarkerException("Enum should have a child"));
         return tracer + variableLiteral.getName() + "_" + child.getName() +
             child.getChild().map(childChild -> "." + toVariableExpression(field, typeReference, childChild, parserArguments, serializerArguments, false, suppressPointerAccess, true)).orElse("");
     }
diff --git a/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java b/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
index 25da83f773..5256ab9c83 100644
--- a/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
+++ b/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
@@ -164,7 +164,7 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
                 return LocalDateTime.class.getSimpleName();
 
         }
-        throw new RuntimeException("Unsupported simple type");
+        throw new FreemarkerException("Unsupported simple type");
     }
 
     public String getPlcValueTypeForTypeReference(TypeReference typeReference) {
@@ -191,7 +191,7 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
                 if (sizeInBits <= 64) {
                     return "PlcULINT";
                 }
-                throw new RuntimeException("Unsupported UINT with bit length " + sizeInBits);
+                throw new FreemarkerException("Unsupported UINT with bit length " + sizeInBits);
             case INT:
                 if (sizeInBits <= 8) {
                     return "PlcSINT";
@@ -205,7 +205,7 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
                 if (sizeInBits <= 64) {
                     return "PlcLINT";
                 }
-                throw new RuntimeException("Unsupported INT with bit length " + sizeInBits);
+                throw new FreemarkerException("Unsupported INT with bit length " + sizeInBits);
             case FLOAT:
             case UFLOAT:
                 if (sizeInBits <= 32) {
@@ -214,7 +214,7 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
                 if (sizeInBits <= 64) {
                     return "PlcLREAL";
                 }
-                throw new RuntimeException("Unsupported REAL with bit length " + sizeInBits);
+                throw new FreemarkerException("Unsupported REAL with bit length " + sizeInBits);
             case STRING:
             case VSTRING:
                 return "PlcSTRING";
@@ -223,7 +223,7 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
             case DATETIME:
                 return "PlcTIME";
         }
-        throw new RuntimeException("Unsupported simple type");
+        throw new FreemarkerException("Unsupported simple type");
     }
 
     @Override
diff --git a/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java b/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java
index 7720fc8d45..7d787e6f47 100644
--- a/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java
+++ b/code-generation/language-python/src/main/java/org/apache/plc4x/language/python/PythonLanguageTemplateHelper.java
@@ -193,7 +193,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
             case DATETIME:
                 return "time.Time";
             default:
-                throw new RuntimeException("Unsupported simple type");
+                throw new FreemarkerException("Unsupported simple type");
         }
     }
 
@@ -541,7 +541,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                 String stringType = "string";
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if (!(encodingTerm instanceof StringLiteral)) {
-                    throw new RuntimeException("Encoding must be a quoted string value");
+                    throw new FreemarkerException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
@@ -576,7 +576,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
         if (valueTerm instanceof StringLiteral) {
             return getWriteBufferWriteMethodCall(logicalName, simpleTypeReference, "\"" + ((StringLiteral) valueTerm).getValue() + "\"", field, writerArgs);
         }
-        throw new RuntimeException("Outputting " + valueTerm.toString() + " not implemented yet. Please continue defining other types in the PythonLanguageHelper.getWriteBufferWriteMethodCall.");
+        throw new FreemarkerException("Outputting " + valueTerm.toString() + " not implemented yet. Please continue defining other types in the PythonLanguageHelper.getWriteBufferWriteMethodCall.");
     }
 
     public String getWriteBufferWriteMethodCall(String logicalName, SimpleTypeReference simpleTypeReference, String fieldName, TypedField field, String... writerArgs) {
@@ -633,9 +633,9 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                 StringTypeReference stringTypeReference = (StringTypeReference) simpleTypeReference;
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 String encoding = encodingTerm.asLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a literal"))
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a literal"))
                     .asStringLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a quoted string value")).getValue();
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a quoted string value")).getValue();
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
                 return "writeBuffer.WriteString(\"" + logicalName + "\", uint32(" + length + "), \"" +
                     encoding + "\", " + fieldName + writerArgsString + ")";
@@ -644,9 +644,9 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                 VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 String encoding = encodingTerm.asLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a literal"))
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a literal"))
                     .asStringLiteral()
-                    .orElseThrow(() -> new RuntimeException("Encoding must be a quoted string value")).getValue();
+                    .orElseThrow(() -> new FreemarkerException("Encoding must be a quoted string value")).getValue();
                 String lengthExpression = toExpression(field, null, vstringTypeReference.getLengthExpression(), null, Collections.singletonList(new DefaultArgument("stringLength", new DefaultIntegerTypeReference(SimpleTypeReference.SimpleBaseType.INT, 32))), true, false);
                 String length = Integer.toString(simpleTypeReference.getSizeInBits());
                 return "writeBuffer.WriteString(\"" + logicalName + "\", uint32(" + lengthExpression + "), \"" +
@@ -739,7 +739,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
         } else if (term instanceof TernaryTerm) {
             return toTernaryTermExpression(field, fieldType, (TernaryTerm) term, parserArguments, serializerArguments, serialize, tracer);
         } else {
-            throw new RuntimeException("Unsupported Term type " + term.getClass().getName());
+            throw new FreemarkerException("Unsupported Term type " + term.getClass().getName());
         }
     }
 
@@ -764,7 +764,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
             }
             return tracer + inlineIf;
         } else {
-            throw new RuntimeException("Unsupported ternary operation type " + ternaryTerm.getOperation());
+            throw new FreemarkerException("Unsupported ternary operation type " + ternaryTerm.getOperation());
         }
     }
 
@@ -835,7 +835,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                 tracer = tracer.dive("case ()");
                 return tracer + "(" + toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, false) + ")";
             default:
-                throw new RuntimeException("Unsupported unary operation type " + unaryTerm.getOperation());
+                throw new FreemarkerException("Unsupported unary operation type " + unaryTerm.getOperation());
         }
     }
 
@@ -874,7 +874,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
             }
             return tracer + toVariableExpression(field, fieldType, (VariableLiteral) term, parserArguments, serializerArguments, serialize, suppressPointerAccess);
         } else {
-            throw new RuntimeException("Unsupported Literal type " + term.getClass().getName());
+            throw new FreemarkerException("Unsupported Literal type " + term.getClass().getName());
         }
     }
 
@@ -988,7 +988,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                     tracer = tracer.dive("complex");
                     ComplexTypeDefinition complexTypeDefinition = (ComplexTypeDefinition) typeDefinition;
                     String childProperty = variableLiteral.getChild()
-                        .orElseThrow(() -> new RuntimeException("complex needs a child"))
+                        .orElseThrow(() -> new FreemarkerException("complex needs a child"))
                         .getName();
                     final Optional<Field> matchingDiscriminatorField = complexTypeDefinition.getFields().stream()
                         .filter(curField -> (curField instanceof DiscriminatorField) && ((DiscriminatorField) curField).getName().equals(childProperty))
@@ -1005,7 +1005,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                         variableAccess = "" + camelCaseToSnakeCase(variableLiteralName);
                     }
                     return tracer + (serialize ? "self." + camelCaseToSnakeCase(variableLiteralName) + "" : variableAccess) +
-                        "." + camelCaseToSnakeCase(variableLiteral.getChild().orElseThrow(() -> new RuntimeException("enum needs a child")).getName()) + "()";
+                        "." + camelCaseToSnakeCase(variableLiteral.getChild().orElseThrow(() -> new FreemarkerException("enum needs a child")).getName()) + "()";
                 }
             }
             // TODO: is this really meant to fall through?
@@ -1089,7 +1089,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
 
     private String toCeilVariableExpression(Field field, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("ceil");
-        Term va = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("CEIL needs at least one arg"))
+        Term va = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("CEIL needs at least one arg"))
             .stream().findFirst().orElseThrow(IllegalStateException::new);
         // The Ceil function expects 64 bit floating point values.
         TypeReference tr = new DefaultFloatTypeReference(SimpleTypeReference.SimpleBaseType.FLOAT, 64);
@@ -1100,12 +1100,12 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
     private String toArraySizeInBytesVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("array size in bytes");
         VariableLiteral va = variableLiteral.getArgs()
-            .orElseThrow(() -> new RuntimeException("ARRAY_SIZE_IN_BYTES needs at least one arg"))
+            .orElseThrow(() -> new FreemarkerException("ARRAY_SIZE_IN_BYTES needs at least one arg"))
             .stream().findFirst().orElseThrow(IllegalStateException::new)
             .asLiteral()
-            .orElseThrow(() -> new RuntimeException("ARRAY_SIZE_IN_BYTES needs a literal"))
+            .orElseThrow(() -> new FreemarkerException("ARRAY_SIZE_IN_BYTES needs a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("ARRAY_SIZE_IN_BYTES needs a variable literal"));
+            .orElseThrow(() -> new FreemarkerException("ARRAY_SIZE_IN_BYTES needs a variable literal"));
         // "io" and "m" are always available in every parser.
         boolean isSerializerArg = "read_buffer".equals(va.getName()) || "write_buffer".equals(va.getName()) || "self".equals(va.getName()) || "element".equals(va.getName());
         if (!isSerializerArg && serializerArguments != null) {
@@ -1129,12 +1129,12 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
     private String toCountVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("count");
         VariableLiteral countLiteral = variableLiteral.getArgs()
-            .orElseThrow(() -> new RuntimeException("Count needs at least one arg"))
+            .orElseThrow(() -> new FreemarkerException("Count needs at least one arg"))
             .get(0)
             .asLiteral()
-            .orElseThrow(() -> new RuntimeException("Count needs a literal"))
+            .orElseThrow(() -> new FreemarkerException("Count needs a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("Count needs a variable literal"));
+            .orElseThrow(() -> new FreemarkerException("Count needs a variable literal"));
         return tracer + (typeReference instanceof SimpleTypeReference ? getCastExpressionForTypeReference(typeReference) : "") + "(len(" +
             toVariableExpression(field, typeReference, countLiteral, parserArguments, serializerArguments, serialize, suppressPointerAccess) +
             "))";
@@ -1143,12 +1143,12 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
     private String toStrLenVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("str-len");
         VariableLiteral countLiteral = variableLiteral.getArgs()
-            .orElseThrow(() -> new RuntimeException("Str-len needs at least one arg"))
+            .orElseThrow(() -> new FreemarkerException("Str-len needs at least one arg"))
             .get(0)
             .asLiteral()
-            .orElseThrow(() -> new RuntimeException("Str-len needs a literal"))
+            .orElseThrow(() -> new FreemarkerException("Str-len needs a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("Str-len needs a variable literal"));
+            .orElseThrow(() -> new FreemarkerException("Str-len needs a variable literal"));
         return tracer + (typeReference instanceof SimpleTypeReference ? getCastExpressionForTypeReference(typeReference) : "") + "(len(" +
             toVariableExpression(field, typeReference, countLiteral, parserArguments, serializerArguments, serialize, suppressPointerAccess) +
             "))";
@@ -1157,15 +1157,15 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
     private String toStaticCallVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("STATIC_CALL");
         StringBuilder sb = new StringBuilder();
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A STATIC_CALL expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A STATIC_CALL expression needs arguments"));
         if (arguments.size() < 1) {
-            throw new RuntimeException("A STATIC_CALL expression expects at least one argument.");
+            throw new FreemarkerException("A STATIC_CALL expression expects at least one argument.");
         }
         // Get the class and method name
         String staticCall = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
+            .orElseThrow(() -> new FreemarkerException("Expecting the first argument of a 'STATIC_CALL' to be a StringLiteral")).
             getValue();
         sb.append(camelCaseToSnakeCase(staticCall)).append("(");
         for (int i = 1; i < arguments.size(); i++) {
@@ -1213,7 +1213,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                         case "encoding":
                             final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                             if (!(encodingTerm instanceof StringLiteral)) {
-                                throw new RuntimeException("Encoding must be a quoted string value");
+                                throw new FreemarkerException("Encoding must be a quoted string value");
                             }
                             String encoding = ((StringLiteral) encodingTerm).getValue();
                             sb.append("\"").append(encoding).append("\"");
@@ -1235,7 +1235,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
                 tracer = tracer.dive("BinaryTerm");
                 sb.append(toBinaryTermExpression(field, typeReference, (BinaryTerm) arg, parserArguments, serializerArguments, serialize, tracer));
             } else {
-                throw new RuntimeException(arg.getClass().getName());
+                throw new FreemarkerException(arg.getClass().getName());
             }
         }
         sb.append(")");
@@ -1244,18 +1244,18 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
 
     private String toCastVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean serialize, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("CAST");
-        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new RuntimeException("A Cast expression needs arguments"));
+        List<Term> arguments = variableLiteral.getArgs().orElseThrow(() -> new FreemarkerException("A Cast expression needs arguments"));
         if (arguments.size() != 2) {
-            throw new RuntimeException("A CAST expression expects exactly two arguments.");
+            throw new FreemarkerException("A CAST expression expects exactly two arguments.");
         }
         VariableLiteral firstArgument = arguments.get(0).asLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a literal"))
+            .orElseThrow(() -> new FreemarkerException("First argument should be a literal"))
             .asVariableLiteral()
-            .orElseThrow(() -> new RuntimeException("First argument should be a Variable literal"));
+            .orElseThrow(() -> new FreemarkerException("First argument should be a Variable literal"));
         StringLiteral typeLiteral = arguments.get(1).asLiteral()
-            .orElseThrow(() -> new RuntimeException("Second argument should be a String literal"))
+            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"))
             .asStringLiteral()
-            .orElseThrow(() -> new RuntimeException("Second argument should be a String literal"));
+            .orElseThrow(() -> new FreemarkerException("Second argument should be a String literal"));
         final TypeDefinition typeDefinition = getTypeDefinitions().get(typeLiteral.getValue());
         StringBuilder sb = new StringBuilder();
         if (typeDefinition.isComplexTypeDefinition()) {
@@ -1281,7 +1281,7 @@ public class PythonLanguageTemplateHelper extends BaseFreemarkerLanguageTemplate
 
     private String toEnumVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean suppressPointerAccess, Tracer tracer) {
         tracer = tracer.dive("enum");
-        VariableLiteral child = variableLiteral.getChild().orElseThrow(() -> new RuntimeException("Enum should have a child"));
+        VariableLiteral child = variableLiteral.getChild().orElseThrow(() -> new FreemarkerException("Enum should have a child"));
         return tracer + variableLiteral.getName() + "_" + child.getName() +
             child.getChild().map(childChild -> "." + toVariableExpression(field, typeReference, childChild, parserArguments, serializerArguments, false, suppressPointerAccess, true)).orElse("");
     }