From 7c56f401ac60756c6ac55bd4e483529cf10a9891 Mon Sep 17 00:00:00 2001 From: nitrix Date: Mon, 3 Feb 2020 22:28:37 +0100 Subject: [PATCH] add error prefix to the runtime exception message --- src/main/java/de/hsrm/compiler/Klang/GetFunctions.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/hsrm/compiler/Klang/GetFunctions.java b/src/main/java/de/hsrm/compiler/Klang/GetFunctions.java index 9250ad9..f9faa5c 100644 --- a/src/main/java/de/hsrm/compiler/Klang/GetFunctions.java +++ b/src/main/java/de/hsrm/compiler/Klang/GetFunctions.java @@ -25,9 +25,12 @@ public class GetFunctions extends KlangBaseVisitor { @Override public Void visitFunctionDef(KlangParser.FunctionDefContext ctx) { String name = ctx.funcName.getText(); + int line = ctx.start.getLine(); + int col = ctx.start.getCharPositionInLine(); if (this.funcs.containsKey(name)) { - throw new Error("Function " + name + " defined multiple times"); + String error = "Function " + name + " defined multiple times."; + throw new Error(Helper.getErrorPrefix(line, col) + error); } Type returnType = Type.getByName(ctx.returnType.type().getText());