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
With Lucky, one goal we have is to provide really nice error messages for you during development to make it easier to solve your issues. To do this, we raise a lot of compile-time errors (or run-time when compile-time isn't possible or doesn't make sense).
One thing I've always thought was strange is that to do this, we just use raise because this lets us stop the execution, and display our message. To me, I think of this as a UI type message. You the developer are trying to use the tool in a way that doesn't work. As opposed to your users of your tool using your app incorrectly.
For example, you're writing a migration and write add_belongs_to but forget to add the on_delete. Do you care about the stacktrace? Would you still care about it if the error message told you exactly where this happened?
What if we had a way to distinguish between an error that needs a nice UI and an actual exception like you used the code correctly, and it didn't work? Anyone have an idea on how we could do that?
What I'm picturing is something like...
macroadd_belongs_to(....)
{%if missing_on_delete %}
{%ErrorMessage.new("Must use 'on_delete' with 'add_belongs_to'.", location_data: ...) %}
{%end%}
end
I have no clue if this is even possible at the crystal level, but it pops up in my mind all the time. My wish would be that this object knows how to make the errors look pretty (i.e. colors, and placement), and it understands how to show the file and line number of where this happened, but ignore the entire crystal stacktrace since it's irrelevant that this comes from the Avram::Migrator::CreateTableStatement.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
With Lucky, one goal we have is to provide really nice error messages for you during development to make it easier to solve your issues. To do this, we raise a lot of compile-time errors (or run-time when compile-time isn't possible or doesn't make sense).
One thing I've always thought was strange is that to do this, we just use
raise
because this lets us stop the execution, and display our message. To me, I think of this as a UI type message. You the developer are trying to use the tool in a way that doesn't work. As opposed to your users of your tool using your app incorrectly.For example, you're writing a migration and write
add_belongs_to
but forget to add theon_delete
. Do you care about the stacktrace? Would you still care about it if the error message told you exactly where this happened?What if we had a way to distinguish between an error that needs a nice UI and an actual exception like you used the code correctly, and it didn't work? Anyone have an idea on how we could do that?
What I'm picturing is something like...
I have no clue if this is even possible at the crystal level, but it pops up in my mind all the time. My wish would be that this object knows how to make the errors look pretty (i.e. colors, and placement), and it understands how to show the file and line number of where this happened, but ignore the entire crystal stacktrace since it's irrelevant that this comes from the
Avram::Migrator::CreateTableStatement
.What are your thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions