You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the 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:
To Reproduce
Steps to reproduce the behavior:
Example:
Generate a show route
Use show route without calling anything: link draw.to_s, to: ::Draws::Show
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 page
Screenshots/code
If applicable, add screenshots/code samples to help explain your problem.
Versions (please complete the following information):
Lucky version (check in shard.lock): 0.29.0
Crystal version (crystal --version): 1.3.2
OS: macOS
The text was updated successfully, but these errors were encountered:
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 parameters
Lucky::Action the base... params could be required or not
Lucky::ParamsNotRequiredAction layered onto the base Lucky::Action... params are not required
In 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.
Describe the bug
When using the
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:
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.2The text was updated successfully, but these errors were encountered: