Skip to content

Bare except catching failure #10

Description

@jayvdb

The follow (bad) Python will catch the exception

try:
    raise Exception("foo")
except:
    print("Got it")

It is transpiled as

begin
  raise Exception, "foo"
rescue
  print("Got it")
end

That only catches the default Ruby exception StandardError.
To catch the exception in Ruby, it needs to catch the top level Ruby exception class.

begin
  raise Exception, "foo"
rescue Exception
  print("Got it")
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions