otobus / event_bus

:surfer: Traceable, extendable and minimalist **event bus** implementation for Elixir with built-in **event store** and **event watcher** based on ETS.

Home Page:https://hexdocs.pm/event_bus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Badly formatted error message for unregistered topic

absolutejam opened this issue · comments

Describe the bug
When trying to send an event to a topic that has not been registered with EventBus.register_topic/1, you get an error like the following:

[warn] Topic(:foo doesn't exist!) doesn't have subscribers

This should be clarified to show either the topic doesn't exist, or it doesn't have subscribers, and not display registration_status within the braces. Additionally, it should print the topic exactly as the user has passed, instead of coercing it to look like an atom, as the log message is confusing if the user has passed a string topic instead of an atom.

Below is the offending line:

"Topic(:#{topic}#{registration_status(topic)}) doesn't have subscribers"

To Reproduce

Send an %EventBus.Model.Event{} to a non-registered topic and observe the warn log entry.

Expected behavior

As per above.


I can submit a PR if you'd like, I just wanted to report and run my suggestions by you before starting.

@absolutejam

Thanks for reporting the issue. I agree on on brackets but for the topic type, if any other type is given the type checker would block it. So, expectation is from the library user to use a type checker. Feel free to create a PR to remove ambiguity inside brackets. Please make sure that tests are covered.