@@ -182,6 +182,18 @@ defmodule Sentry.Event do
182182 end )
183183 end
184184
185+ defmacrop put_source_context ( frame , file , line_number ) do
186+ if Config . enable_source_code_context ( ) do
187+ quote do
188+ do_put_source_context ( unquote ( frame ) , unquote ( file ) , unquote ( line_number ) )
189+ end
190+ else
191+ quote do
192+ unquote ( frame )
193+ end
194+ end
195+ end
196+
185197 @ spec stacktrace_to_frames ( Exception . stacktrace ( ) ) :: [ map ]
186198 def stacktrace_to_frames ( stacktrace ) do
187199 in_app_module_whitelist = Config . in_app_module_whitelist ( )
@@ -208,18 +220,15 @@ defmodule Sentry.Event do
208220 |> Enum . reverse ( )
209221 end
210222
211- @ spec put_source_context ( map ( ) , String . t ( ) , integer ( ) ) :: map ( )
212- def put_source_context ( frame , file , line_number ) do
213- if @ source_code_context_enabled do
214- { pre_context , context , post_context } =
215- Sentry.Sources . get_source_context ( @ source_files , file , line_number )
223+ @ spec do_put_source_context ( map ( ) , String . t ( ) , integer ( ) ) :: map ( )
224+ def do_put_source_context ( frame , file , line_number ) do
225+ { pre_context , context , post_context } =
226+ Sentry.Sources . get_source_context ( @ source_files , file , line_number )
216227
217- Map . put ( frame , :context_line , context )
218- |> Map . put ( :pre_context , pre_context )
219- |> Map . put ( :post_context , post_context )
220- else
221- frame
222- end
228+ frame
229+ |> Map . put ( :context_line , context )
230+ |> Map . put ( :pre_context , pre_context )
231+ |> Map . put ( :post_context , post_context )
223232 end
224233
225234 @ spec culprit_from_stacktrace ( Exception . stacktrace ( ) ) :: String . t ( ) | nil
0 commit comments