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

Attempting to use dashes in path variable naming produces unhelpful error #1235

Closed
matthewmcgarvey opened this issue Aug 12, 2020 · 1 comment · Fixed by #1238
Closed

Attempting to use dashes in path variable naming produces unhelpful error #1235

matthewmcgarvey opened this issue Aug 12, 2020 · 1 comment · Fixed by #1238
Labels
improve error experience Make errors nicer to deal with

Comments

@matthewmcgarvey
Copy link
Member

Say I try to define a route like:

get "/users/:user-id" do
  ...
end

It currently produces an error like:

There was a problem expanding macro 'add_route'

Code in macro 'match'

 5 | add_route(:get, "/users/:user-id", Users::Show)
     ^
Called macro defined in src/lucky/routable.cr:191:3

 191 | macro add_route(method, path, action)

Which expanded to:

 >  7 |     
 >  8 |       
 >  9 |       def user-id : String
                      ^
Error: unexpected token: -1

It would be more helpful for users to check the path variable's format before trying to generate the methods and produce a descriptive error if they stray down this path.

@jwoertink jwoertink added the improve error experience Make errors nicer to deal with label Aug 12, 2020
@paulcsmith
Copy link
Member

Nice! Thanks for opening this. I totally agree we should check for that and raise a better error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve error experience Make errors nicer to deal with
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants