@@ -361,6 +361,10 @@ defmodule Sentry.LoggerHandler do
361361
362362 capture ( :message , "** (stop) #{ Exception . format_exit ( reason ) } " , sentry_opts , config )
363363
364+ # Special-case Ranch messages because their formatting is their formatting.
365+ % { format: ~c" Ranch listener ~p" ++ _ , args: args } ->
366+ capture_from_ranch_error ( args , sentry_opts , config )
367+
364368 _ ->
365369 capture ( :message , inspect ( report ) , sentry_opts , config )
366370 end
@@ -587,6 +591,28 @@ defmodule Sentry.LoggerHandler do
587591 capture ( :message , string_message , sentry_opts , config )
588592 end
589593
594+ # This is only causing issues on OTP 25 apparently.
595+ # TODO: remove special-cased Ranch handling when we depend on OTP 26+.
596+ defp capture_from_ranch_error (
597+ _args = [
598+ _listener ,
599+ _connection_process ,
600+ _stream ,
601+ _request_process ,
602+ _reason = { { exception , stacktrace } , _ }
603+ ] ,
604+ sentry_opts ,
605+ % __MODULE__ { } = config
606+ )
607+ when is_exception ( exception ) do
608+ sentry_opts = Keyword . merge ( sentry_opts , stacktrace: stacktrace , handled: false )
609+ capture ( :exception , exception , sentry_opts , config )
610+ end
611+
612+ defp capture_from_ranch_error ( args , sentry_opts , % __MODULE__ { } = config ) do
613+ capture ( :message , "Ranch listener error: #{ inspect ( args ) } " , sentry_opts , config )
614+ end
615+
590616 defp add_extra_to_sentry_opts ( sentry_opts , new_extra ) do
591617 Keyword . update ( sentry_opts , :extra , % { } , & Map . merge ( new_extra , & 1 ) )
592618 end
0 commit comments