{"id":18658371,"url":"https://github.com/shime/rescue_from_ruby","last_synced_at":"2025-11-05T23:30:32.789Z","repository":{"id":8964507,"uuid":"10705124","full_name":"shime/rescue_from_ruby","owner":"shime","description":"ActiveSupport::Rescuable for plain old Ruby objects","archived":false,"fork":false,"pushed_at":"2013-06-15T12:35:07.000Z","size":108,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T15:26:43.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-15T10:47:24.000Z","updated_at":"2021-01-25T21:53:39.000Z","dependencies_parsed_at":"2022-09-06T01:11:28.688Z","dependency_job_id":null,"html_url":"https://github.com/shime/rescue_from_ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Frescue_from_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Frescue_from_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Frescue_from_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Frescue_from_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shime","download_url":"https://codeload.github.com/shime/rescue_from_ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239475962,"owners_count":19645041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T07:32:40.920Z","updated_at":"2025-11-05T23:30:32.754Z","avatar_url":"https://github.com/shime.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"*ActiveSupport's* `rescue_from` is elegant, but you can use it in Rails controllers only.\n\nThis gem makes it available on every Ruby object.\n\n## How to do it?\n\nIf you don't want to have additional gem for this, you can do everything manually. You'll have to load *ActiveSupport*\nin order to do so.\n\n```ruby\n# encoding: utf-8\nrequire \"active_support\"\n\nclass C╯°□°D╯︵┻━┻ \u003c StandardError; end\n\nclass Failer\n  def throw_table!\n    raise C╯°□°D╯︵┻━┻.new \"I've had enough of this!\"\n  end\nend\n\nmodule FailerExceptionHandler\n  def self.included(base)\n    base.extend ClassMethods\n  end\n\n  module ClassMethods\n    def with_rescue_block(exception_class, *names, \u0026blk)\n      instance_eval do\n        rescue_from(exception_class, \u0026blk)\n      end\n\n      names.each do |name|\n        method = instance_method(name)\n\n        define_method(name) do |*args, \u0026block|\n          begin\n            method.bind(self).call(*args, \u0026block)\n          rescue exception_class =\u003e ex\n            rescue_with_handler(ex) || raise\n          end\n        end\n      end\n    end\n  end\nend\n\nclass Failer\n  include ActiveSupport::Rescuable\n  include FailerExceptionHandler\n\n  with_rescue_block(C╯°□°D╯︵┻━┻, *instance_methods) do |exception|\n    puts \"Worker: #{exception.message}\\nUniverse: Calm down, dude!\"\n  end\nend\n\nFailer.new.throw_table!\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'rescue_from_ruby'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rescue_from_ruby\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshime%2Frescue_from_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshime%2Frescue_from_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshime%2Frescue_from_ruby/lists"}