src/format.cc

changeset 79
2425fa6a4f21
parent 75
bf8c57437231
child 81
071715c17296
--- a/src/format.cc	Fri Jan 17 21:42:02 2014 +0200
+++ b/src/format.cc	Fri Jan 17 22:55:13 2014 +0200
@@ -31,6 +31,7 @@
 #include <cstdio>
 #include "main.h"
 #include "format.h"
+#include "lexer.h"
 
 static void draw_pos (const string& fmt, int pos)
 {
@@ -121,4 +122,18 @@
 {
 	string out = format_args (args);
 	fprintf (fp, "%s", out.chars());
+}
+
+void do_error (string msg)
+{
+	lexer* lx = lexer::get_main_lexer();
+	string fileinfo;
+
+	if (lx != null && lx->has_valid_token())
+	{
+		lexer::token* tk = lx->get_token();
+		fileinfo = format ("%1:%2:%3: ", tk->file, tk->line, tk->column);
+	}
+
+	throw script_error (fileinfo + msg);
 }
\ No newline at end of file

mercurial