Mercurial > prosody-modules
changeset 4290:2c73544e33ea
mod_sentry: Automatically attach exceptions for errors used in log parameters
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 09 Dec 2020 16:30:21 +0000 |
parents | de91b7cb7342 |
children | a0d20e378670 |
files | mod_sentry/mod_sentry.lua |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_sentry/mod_sentry.lua Wed Dec 09 16:22:22 2020 +0000 +++ b/mod_sentry/mod_sentry.lua Wed Dec 09 16:30:21 2020 +0000 @@ -9,6 +9,7 @@ end local loggingmanager = require "core.loggingmanager"; +local errors = require "util.error"; local format = require "util.format".format; local default_config = assert(module:get_option("sentry"), "Please provide a 'sentry' configuration option"); @@ -61,8 +62,17 @@ level = "warning"; end + local event = sentry:event(level, name):message(format(message, ...)); + + local params = { ... }; + for i = 1, select("#", ...) do + if errors.is_error(params[i]) then + event:add_exception(params[i]); + end + end + submitting = true; - sentry:event(level, name):message(format(message, ...)):send():catch(sentry_error_handler); + event:send():catch(sentry_error_handler); submitting = false; end; end