@@ -182,6 +182,16 @@ 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+ macro_put_source_context ( unquote ( frame ) , unquote ( file ) , unquote ( line_number ) )
189+ end
190+ else
191+ frame
192+ end
193+ end
194+
185195 @ spec stacktrace_to_frames ( Exception . stacktrace ( ) ) :: [ map ]
186196 def stacktrace_to_frames ( stacktrace ) do
187197 in_app_module_whitelist = Config . in_app_module_whitelist ( )
@@ -208,18 +218,14 @@ defmodule Sentry.Event do
208218 |> Enum . reverse ( )
209219 end
210220
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 )
221+ @ spec macro_put_source_context ( map ( ) , String . t ( ) , integer ( ) ) :: map ( )
222+ def macro_put_source_context ( frame , file , line_number ) do
223+ { pre_context , context , post_context } =
224+ Sentry.Sources . get_source_context ( @ source_files , file , line_number )
216225
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
226+ Map . put ( frame , :context_line , context )
227+ |> Map . put ( :pre_context , pre_context )
228+ |> Map . put ( :post_context , post_context )
223229 end
224230
225231 @ spec culprit_from_stacktrace ( Exception . stacktrace ( ) ) :: String . t ( ) | nil
0 commit comments