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

Symbol conversion procs should report better message #70

Open
enebo opened this issue Oct 21, 2013 · 1 comment
Open

Symbol conversion procs should report better message #70

enebo opened this issue Oct 21, 2013 · 1 comment

Comments

@enebo
Copy link
Member

enebo commented Oct 21, 2013

When you call a color converter (just an example) which takes a symbol we get a rather weird error message to anyone who is not a JRubyFX hacker:

Exception running Application:
#<TypeError: cannot convert instance of class org.jruby.RubySymbol to class javafx.scene.paint.Paint>
/Users/enebo/work/jrubyfx/lib/jrubyfx/core_ext/precompiled.rb:908:in `fill='

Now we know something went wrong with fill= but this is pretty confusing to new users and we can give better feed back. Here is what I have a patch for (I will commit it as a discussion provoker):

Exception running Application:
#<ArgumentError: No such color: redbull>
/Users/enebo/work/jrubyfx/lib/jrubyfx/utils/common_converters.rb:144:in `CommonConverters'
org/jruby/RubyProc.java:264:in `call'
/Users/enebo/work/jrubyfx/lib/jrubyfx/core_ext/precompiled.rb:908:in `fill='

So the backtrace now shows common converters and the proc call for the converter but the message is likely to be really obvious. It would be possible to make a much more sophisticated coercion mechanism but I feel this is a big improvement for a tiny amount of work.

@enebo
Copy link
Member Author

enebo commented Oct 21, 2013

c6e37b2 is a commit which enables this behavior for color converter. We can revert this if we decide we dislike it but I hate seeing the RubySymbol stuff. I think we should add this to all symbol-based converters since a symbol is always an invalid type to pass to a FX method.

I played a little with a more robust mechanism to converters to report at he proper place but without a lot of codegen I don't see a nice way of doing it.

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