diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-12-27 15:16:18 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-12-27 15:16:18 +0100 |
commit | 09c61e13767f7b77618949f422f229b638381088 (patch) | |
tree | 4729cdeb166e05b4e8b6e594be3f8487378aacad /lib | |
parent | 3b9a6049adf3ee6844a81622c297dd893836f79d (diff) | |
parent | fe71548844715d796b9a6d2dd5234f70cf080f13 (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `README.md`: We have completely different contents. Kept our version. - `package.json`: Not a real conflict, just an upstream dependency udpated textually too close to a glitch-soc-only dependency. Updated dependencies like upstream. - `streaming/index.js`: Conflict due to code style changes on parts that were modified in glitch-soc to handle local-only toots. Changed style according to upstream.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sidekiq_error_handler.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/sidekiq_error_handler.rb b/lib/sidekiq_error_handler.rb new file mode 100644 index 000000000..358afd540 --- /dev/null +++ b/lib/sidekiq_error_handler.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class SidekiqErrorHandler + BACKTRACE_LIMIT = 3 + + def call(*) + yield + rescue Mastodon::HostValidationError + # Do not retry + rescue => e + limit_backtrace_and_raise(e) + ensure + socket = Thread.current[:statsd_socket] + socket&.close + Thread.current[:statsd_socket] = nil + end + + private + + def limit_backtrace_and_raise(exception) + exception.set_backtrace(exception.backtrace.first(BACKTRACE_LIMIT)) + raise exception + end +end |