From cc5904ed66b08d0d846e098ae51a60460633719a Mon Sep 17 00:00:00 2001
From: funkydude <funkydude@users.noreply.github.com>
Date: Sat, 21 Jul 2018 20:23:08 +0100
Subject: [PATCH] Simplify messages with no stack or locals.

---
 core.lua | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/core.lua b/core.lua
index a18889e..3240a77 100644
--- a/core.lua
+++ b/core.lua
@@ -207,11 +207,18 @@ do
 	end
 	addon.ColorLocals = colorLocals
 
-	local errorFormat = "%dx %s\n\nLocals:\n%s"
+	local errorFormat = "%dx %s"
+	local errorFormatLocals = "%dx %s\n\nLocals:\n%s"
 	function addon:FormatError(err)
-		local s = colorStack(tostring(err.message) .. "\n" .. tostring(err.stack))
-		local l = colorLocals(tostring(err.locals))
-		return errorFormat:format(err.counter or -1, s, l)
+		if not err.locals then
+			local s = colorStack(tostring(err.message) .. (err.stack and "\n"..tostring(err.stack) or ""))
+			local l = colorLocals(tostring(err.locals))
+			return errorFormat:format(err.counter or -1, s, l)
+		else
+			local s = colorStack(tostring(err.message) .. (err.stack and "\n"..tostring(err.stack) or ""))
+			local l = colorLocals(tostring(err.locals))
+			return errorFormatLocals:format(err.counter or -1, s, l)
+		end
 	end
 end