# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1607525500 0
# Node ID 8143fd2f138b46d75fbc7034ce6efebbe3645a5a
# Parent  b8589256b404f87d49e4dc07ae1ccc5c0da50793
util.error: Switch to util.debug traceback tables and remove display_tracebacks option

diff -r b8589256b404 -r 8143fd2f138b util/error.lua
--- a/util/error.lua	Wed Dec 09 14:00:13 2020 +0000
+++ b/util/error.lua	Wed Dec 09 14:51:40 2020 +0000
@@ -1,16 +1,13 @@
 local id = require "util.id";
 
+local util_debug; -- only imported on-demand
+
 -- Library configuration (see configure())
 local auto_inject_traceback = false;
-local display_tracebacks = false;
-
 
 local error_mt = { __name = "error" };
 
 function error_mt:__tostring()
-	if display_tracebacks and self.context.traceback then
-		return ("error<%s:%s:%s:%s>"):format(self.type, self.condition, self.text or "", self.context.traceback);
-	end
 	return ("error<%s:%s:%s>"):format(self.type, self.condition, self.text or "");
 end
 
@@ -19,11 +16,11 @@
 end
 
 local function configure(opt)
-	if opt.display_tracebacks ~= nil then
-		display_tracebacks = opt.display_tracebacks;
-	end
 	if opt.auto_inject_traceback ~= nil then
 		auto_inject_traceback = opt.auto_inject_traceback;
+		if auto_inject_traceback then
+			util_debug = require "util.debug";
+		end
 	end
 end
 
@@ -53,7 +50,7 @@
 	context = context or {};
 
 	if auto_inject_traceback then
-		context.traceback = debug.traceback("error stack", 2);
+		context.traceback = util_debug.get_traceback_table(nil, 2);
 	end
 
 	local error_instance = setmetatable({