Open grepsedawk opened 2 years ago
Seems that the standard compiler error has changed now with Crystal v1.5.0.
Thinking about what would be expected and using my picture as an example... ideally it should point to the call to link
saying that you can't pass LinkHelpers::Show
and point at where link
was called. I can't think of a way to accomplish that with the way things are right now. The most obvious thing to reach for would be to add an overload route
method that takes no arguments to actions that have required parameters but I think that would have to provide a super generic error message and still not point to the line we want it to.
To think outside of the current implementation, we could have to have three different interfaces.
Lucky::RouteHelper
that's what you get when you provide parametersLucky::Action
the base... params could be required or notLucky::ParamsNotRequiredAction
layered onto the base Lucky::Action
... params are not requiredIn the macro process of the action class, you'd extend the action with Lucky::ParamsNotRequiredAction
if there are no required params. That module would give a route
method that would be removed from Lucky::Action
. At least in the Lucky::LinkHelpers
module you'd replace the methods that take in Lucky::Action
with Lucky::ParamsNotRequiredAction
. That way, if you pass in an action that requires params without providing them, it would fail to compile exactly where we want it to. The only issue is, it wouldn't quite explain itself as we'd like so we'd likely have to provide an implementation of the methods with Lucky::Action
and provide a clearer error message.
This is all just off the top of my head, so I have no idea if it'd even work. I'll look into it more as I'm interested in it right now.
I wonder what this error message will look like in Crystal 1.6 with the errors changing https://github.com/crystal-lang/crystal/pull/12469
Describe the bug When using the![image](https://user-images.githubusercontent.com/6721355/150656015-40d691de-5e28-477f-8a0f-db57e39939b3.png)
link_to
macro with a path that has required attributes, the error provided is not very helpful.Then jumping through the full error trace, our code's call doesn't bring much information either:![image](https://user-images.githubusercontent.com/6721355/150656155-e89923d7-6156-428d-b007-f828fdb8f8c1.png)
To Reproduce Steps to reproduce the behavior:
Expected behavior
Catch the error for the user, suggest that the required attributes might need to be called using
.with
on the ShowPage to pass the required arguments into the pageScreenshots/code If applicable, add screenshots/code samples to help explain your problem.
Versions (please complete the following information):
crystal --version
): 1.3.2