Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't issue good compile-time errors re bad arguments #41

Open
garthk opened this issue Aug 6, 2020 · 0 comments
Open

Can't issue good compile-time errors re bad arguments #41

garthk opened this issue Aug 6, 2020 · 0 comments

Comments

@garthk
Copy link

garthk commented Aug 6, 2020

I'm raising because my decorator arguments are bad, and the stack trace isn't giving as much help as I like to provide:

== Compilation error in file lib/my_app/my_module.ex ==
** (ArgumentError) event_name must be made of atoms
    lib/telemetry_decorator.ex:47: anonymous fn/2 in TelemetryDecorator.telemetry/3
    (elixir 1.10.4) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/telemetry_decorator.ex:47: TelemetryDecorator.telemetry/3
    lib/decorator/decorate.ex:164: Decorator.Decorate.apply_decorator/3
    (elixir 1.10.4) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/decorator/decorate.ex:128: Decorator.Decorate.decorate/4
    (elixir 1.10.4) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    expanding macro: Decorator.Decorate.before_compile/1

That not bad as a clue, but it'd be great to put the line number of the decoration in there. I can scrape some from context.args, if there are any; more from body, but I can't get the filename anywhere.

Possible fixes:

  • Pass the filename and line number in Decorator.Decorate.Context

  • Pass the full __CALLER__ in Decorator.Decorate.Context

  • try around calling the decorator; rescue; insert the decorator into the stack trace; reraise

I'm happy to raise a PR for either, or some way that you think would be cleaner; what would you feel OK merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant