Comparison

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
comparison
equal deleted inserted replaced
4284:b7045af1e5b7 4285:e67081d1f835
52 end 52 end
53 return data; 53 return data;
54 end 54 end
55 55
56 local function error_to_sentry_exception(e) 56 local function error_to_sentry_exception(e)
57 return { 57 local exception = {
58 type = e.condition or (e.code and tostring(e.code)) or nil; 58 type = e.condition or (e.code and tostring(e.code)) or nil;
59 value = e.text or tostring(e); 59 value = e.text or tostring(e);
60 context = e.source; 60 context = e.source;
61 mechanism = { 61 mechanism = {
62 type = "generic"; 62 type = "generic";
63 description = "Prosody error object"; 63 description = "Prosody error object";
64 synthetic = not not e.context.wrapped_error; 64 synthetic = not not e.context.wrapped_error;
65 data = get_error_data(e.instance_id, e.context); 65 data = get_error_data(e.instance_id, e.context);
66 }; 66 };
67 }; 67 };
68 local traceback = e.context.traceback;
69 if traceback and type(traceback) == "table" then
70 local frames = {};
71 for i = #traceback, 1 do
72 local frame = traceback[i];
73 table.insert(frames, {
74 ["function"] = frame.info.name;
75 filename = frame.info.short_src;
76 lineno = frame.info.currentline;
77 });
78 end
79 exception.frames = frames;
80 end
81 return exception;
68 end 82 end
69 83
70 local sentry_event_methods = {}; 84 local sentry_event_methods = {};
71 local sentry_event_mt = { __index = sentry_event_methods }; 85 local sentry_event_mt = { __index = sentry_event_methods };
72 86