Skip to content

Commit

Permalink
run the formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
davydog187 committed Feb 17, 2020
1 parent 95bb601 commit f157bb3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
15 changes: 11 additions & 4 deletions lib/commanded/event/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,9 @@ defmodule Commanded.Event.Handler do
@doc false
@impl GenServer
def handle_info(message, state) do
Logger.error(fn -> describe(state) <> " received unexpected message: " <> inspect(message, pretty: true) end)
Logger.error(fn ->
describe(state) <> " received unexpected message: " <> inspect(message, pretty: true)
end)

{:noreply, state}
end
Expand Down Expand Up @@ -622,17 +624,22 @@ defmodule Commanded.Event.Handler do
{:error, reason} = error ->
Logger.error(fn ->
describe(state) <>
" failed to handle event #{inspect(event, pretty: true)} due to: #{inspect(reason, pretty: true)}"
" failed to handle event #{inspect(event, pretty: true)} due to: #{
inspect(reason, pretty: true)
}"
end)

handle_event_error(error, event, state, context)

{:error, reason, stacktrace} ->
Logger.error(fn ->
describe(state) <>
" failed to handle event #{inspect(event, pretty: true)} due to: #{inspect(reason, pretty: true)}"
" failed to handle event #{inspect(event, pretty: true)} due to: #{
inspect(reason, pretty: true)
}"
end)
Logger.error(fn -> Exception.format(:error, reason, stacktrace) end)

Logger.error(fn -> Exception.format(:error, reason, stacktrace) end)

handle_event_error({:error, reason}, event, state, context)
end
Expand Down
1 change: 0 additions & 1 deletion test/event/default_event_handler_error_handling_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ defmodule Commanded.Event.DefaultEventHandlerErrorHandlingTest do
assert_receive {:DOWN, ^ref, _, _, _}
refute Process.alive?(handler)
end

end
2 changes: 1 addition & 1 deletion test/event/handle_event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ defmodule Commanded.Event.HandleEventTest do
"Commanded.ExampleDomain.BankAccount.AccountBalanceHandler received unexpected message: :unexpected_message"
end


test "should print the stack trace on errors", %{handler: handler} do
import ExUnit.CaptureLog

events = [
%ErrorEvent{}
]
Expand Down
2 changes: 1 addition & 1 deletion test/event/support/error_event.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Commanded.Event.ErrorEvent do
@moduledoc false
defstruct [field: nil]
defstruct field: nil
end

0 comments on commit f157bb3

Please sign in to comment.