comparison mod_sentry/sentry.lib.lua @ 4288:26bc1ae88ccb

mod_sentry: Ensure frames gets encoded as a JSON array, even if empty
author Matthew Wild <mwild1@gmail.com>
date Wed, 09 Dec 2020 16:22:04 +0000
parents 2c4157785b42
children de91b7cb7342
comparison
equal deleted inserted replaced
4287:2c4157785b42 4288:26bc1ae88ccb
1 local array = require "util.array";
1 local hex = require "util.hex"; 2 local hex = require "util.hex";
2 local random = require "util.random"; 3 local random = require "util.random";
3 local url = require "socket.url"; 4 local url = require "socket.url";
4 local datetime = require "util.datetime".datetime; 5 local datetime = require "util.datetime".datetime;
5 local http = require 'net.http' 6 local http = require 'net.http'
67 data = get_error_data(e.instance_id, e.context); 68 data = get_error_data(e.instance_id, e.context);
68 }; 69 };
69 }; 70 };
70 local traceback = e.context.traceback; 71 local traceback = e.context.traceback;
71 if traceback and type(traceback) == "table" then 72 if traceback and type(traceback) == "table" then
72 local frames = {};
73 for i = #traceback, 1 do 73 for i = #traceback, 1 do
74 local frames = array();
74 local frame = traceback[i]; 75 local frame = traceback[i];
75 table.insert(frames, { 76 table.insert(frames, {
76 ["function"] = frame.info.name; 77 ["function"] = frame.info.name;
77 filename = frame.info.short_src; 78 filename = frame.info.short_src;
78 lineno = frame.info.currentline; 79 lineno = frame.info.currentline;