Skip to content

Errors with try/catch conversions #226

@TheBrenny

Description

@TheBrenny

Hey! First time user, first time lover!

I'm converting the WinRB project from Ruby to JS and for the most part it's been working well, minus a few hiccups with private and protected keywords and ranges. I can work with commenting those blocks out, doing the conversion, and then reworking the resulting comments into usable JS. However, I've been running into some issues with try/catchs:


unknown AST type ensure at /app/lib/winrm/shells/base.rb:130:8 (Ruby2JS::Error) (source)

I've run into what I think is missing support for the ensure keyword. Now I don't know Ruby at all (I mean, at all) but a quick Google confirmed my assumption that it's equivalent to the finally keyword. Again, I don't know Ruby, but point me to the right spot and I could probably give it a crack (this language seems cool...)


multiple recovers with different exception variables at /app/lib/winrm/shells/power_shell.rb:71:10 (Ruby2JS::Error) (source)

This one too... I think a solution be to create a catch(e) block and use if/else to match on the exception's type. I'd love to work this out, but I think this one isn't as straightforward.


unknown AST type retry at /app/lib/winrm/shells/retryable.rb:40:8 (Ruby2JS::Error) (source)

I think a valid solution would be to call the function name again, either as a recursion or a setTimeout(fn,0) (the former doesn't have any async issues, but relies on safe recursion management - but that's the dev's problem to manage... Right?)


And this one's just whack: /usr/local/rvm/gems/default/gems/ruby2js-5.1.2/lib/ruby2js.rb:357:in rescue in parse': line 7, column 1: literal contains escape sequences incompatible with UTF-8 (Ruby2JS::SyntaxError)
in file /app/tests/spec/psrp/message_defragmenter_spec.rb` (source)

I imagine that Ruby2JS is trying to interpret these escape characters literally to generate a resultant string, but I think it shouldn't be doing this. Maybe it can do some sort of detection to determine if it's not ascii and print it, or maybe it can try and read the raw input to copy the string content, but ultimately, this is outside of my bag of knowledge...


Again, love the work, and eager to help if I can!

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