commanded / commanded

Use Commanded to build Elixir CQRS/ES applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stacktrace in event handler error?

pirvudoru opened this issue · comments

Thanks for the great work you are doing. Launched an application in production recently and so far so good.

I have a question related to when errors occur for event handlers.
As I understand, the Stacktrace has been added to the logs in this PR #340

But I am getting this:

MyApp.EventHandlers.MyEventsHandler failed to handle event %Commanded.EventStore.RecordedEvent{
  causation_id: "4a8f5ac3-4047-451f-93f9-acc5cfbfd4e1",
  correlation_id: "ee8755d2-b8cc-462a-8fb4-4f7a4c7032d6",
  created_at: ~U[2023-01-29 09:56:33.953997Z],
  data: %MyApp.Events.MyEvent{
    uuid: "9bd2bbcb-f890-4b1e-9a8f-5832bed7ca7e"
  },
  event_id: "3cc15444-bd18-4d4d-9dcf-910903286138",
  event_number: 11711,
  event_type: "Elixir.MyApp.Events.MyEvent",
  metadata: %{},
  stream_id: "9bd2bbcb-f890-4b1e-9a8f-5832bed7ca7e",
  stream_version: 1
} due to: %ArgumentError{
  message: "comparison with nil is forbidden as it is unsafe. If you want to check if a value is nil, use is_nil/1 instead"
}

My mix.lock lists:

  "commanded": {:hex, :commanded, "1.4.1", "928b8357ebe1817f88b109693b4d717d20c11ef45cebe42a71dee0a56be36c2c", [:mix], [{:backoff, "~> 1.1", [hex: :backoff, repo: "hexpm", optional: false]}, {:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_registry, "~> 0.2 or ~> 0.3", [hex: :telemetry_registry, repo: "hexpm", optional: false]}], "hexpm", "6cd94b4b3369871c030a83b934548720cc834ec7b8549ba031510120aceb7ef9"},

Is there any way to log the stacktrace for the error ? I've seen the same thing for MatchError-- no stacktrace. A stacktrace in these cases would be really helpful.

I've opened a PR for this. Let me know if it looks good.