Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions lib/sentry/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ defmodule Sentry.Event do
end)
end

defmacrop put_source_context(frame, file, line_number) do
if Config.enable_source_code_context() do
quote do
macro_put_source_context(unquote(frame), unquote(file), unquote(line_number))
end
else
frame
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to quote this?

end
end

@spec stacktrace_to_frames(Exception.stacktrace()) :: [map]
def stacktrace_to_frames(stacktrace) do
in_app_module_whitelist = Config.in_app_module_whitelist()
Expand All @@ -208,18 +218,14 @@ defmodule Sentry.Event do
|> Enum.reverse()
end

@spec put_source_context(map(), String.t(), integer()) :: map()
def put_source_context(frame, file, line_number) do
if @source_code_context_enabled do
{pre_context, context, post_context} =
Sentry.Sources.get_source_context(@source_files, file, line_number)
@spec macro_put_source_context(map(), String.t(), integer()) :: map()
def macro_put_source_context(frame, file, line_number) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this private and rename it to "do_put_source_context" instead of macro. Its pretty common.

{pre_context, context, post_context} =
Sentry.Sources.get_source_context(@source_files, file, line_number)

Map.put(frame, :context_line, context)
|> Map.put(:pre_context, pre_context)
|> Map.put(:post_context, post_context)
else
frame
end
Map.put(frame, :context_line, context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start this with frame |>

|> Map.put(:pre_context, pre_context)
|> Map.put(:post_context, post_context)
end

@spec culprit_from_stacktrace(Exception.stacktrace()) :: String.t() | nil
Expand Down