Diff

mod_sentry/sentry.lib.lua @ 4285:e67081d1f835

mod_sentry: Support for including stack frames in exception events
author Matthew Wild <mwild1@gmail.com>
date Wed, 09 Dec 2020 15:15:17 +0000
parent 4284:b7045af1e5b7
child 4286:64f400a38a30
line wrap: on
line diff
--- a/mod_sentry/sentry.lib.lua	Wed Dec 09 12:21:17 2020 +0000
+++ b/mod_sentry/sentry.lib.lua	Wed Dec 09 15:15:17 2020 +0000
@@ -54,7 +54,7 @@
 end
 
 local function error_to_sentry_exception(e)
-	return {
+	local exception = {
 		type = e.condition or (e.code and tostring(e.code)) or nil;
 		value = e.text or tostring(e);
 		context = e.source;
@@ -65,6 +65,20 @@
 			data = get_error_data(e.instance_id, e.context);
 		};
 	};
+	local traceback = e.context.traceback;
+	if traceback and type(traceback) == "table" then
+		local frames = {};
+		for i = #traceback, 1 do
+			local frame = traceback[i];
+			table.insert(frames, {
+				["function"] = frame.info.name;
+				filename = frame.info.short_src;
+				lineno = frame.info.currentline;
+			});
+		end
+		exception.frames = frames;
+	end
+	return exception;
 end
 
 local sentry_event_methods = {};