Skip to content

Symbol conversion procs should report better message #70

Open
@enebo

Description

@enebo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions