{"id":16380994,"url":"https://github.com/anthonator/errawr","last_synced_at":"2025-10-17T16:17:28.568Z","repository":{"id":11567349,"uuid":"14054861","full_name":"anthonator/errawr","owner":"anthonator","description":"Easily define and raise localized errors","archived":false,"fork":false,"pushed_at":"2015-07-18T05:34:59.000Z","size":284,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-27T16:14:09.006Z","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/anthonator.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-11-01T21:39:41.000Z","updated_at":"2023-03-17T12:03:10.000Z","dependencies_parsed_at":"2022-07-13T10:10:26.640Z","dependency_job_id":null,"html_url":"https://github.com/anthonator/errawr","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/anthonator/errawr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonator%2Ferrawr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonator%2Ferrawr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonator%2Ferrawr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonator%2Ferrawr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthonator","download_url":"https://codeload.github.com/anthonator/errawr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonator%2Ferrawr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271119388,"owners_count":24702670,"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","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-11T03:53:05.375Z","updated_at":"2025-10-17T16:17:23.524Z","avatar_url":"https://github.com/anthonator.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Errawr\n\nA framework for effectively defining and raising localized errors.\n\n[![Build Status](https://travis-ci.org/anthonator/errawr.png?branch=master)](https://travis-ci.org/anthonator/errawr) [![Dependency Status](https://gemnasium.com/anthonator/errawr.png)](https://gemnasium.com/anthonator/errawr) [![Coverage Status](https://coveralls.io/repos/anthonator/errawr/badge.png?branch=master)](https://coveralls.io/r/anthonator/errawr?branch=master) [![Code Climate](https://codeclimate.com/github/anthonator/errawr.png)](https://codeclimate.com/github/anthonator/errawr)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'errawr'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install errawr\n\n## Usage\n\n### Defining and Raising Errors\n\nErrawr uses [I18n](https://github.com/svenfuchs/i18n) for easily managing error\nlocalizations. Just define an error in a locale file. Make sure to use the\n```errawr``` key.\n\n```yaml\nen:\n  errawr:\n    your_error:\n      message: My awesome error message\n      metadata:\n        http_status: 400\n```\n\nThen just raise your exception using the `#error!` method.\n\n```ruby\nbegin\n  Errawr.error!(:your_error)\nrescue =\u003e e\n  puts e.metadata[:http_status] # Will return 400\nend\n```\n\nNeed to add more locale files? Use I18n's standard ```load_path```.\n\n```ruby\nI18n.load_path += Dir.glob('lib/your_lib/locales/*.{rb,yml}')\n```\n\n### Metadata\n\nIt's possible to add additional information to a registered error through\nmetadata. Just specify a ```metadata``` hash when throwing an error:\n\n```ruby\nbegin\n  Errawr.error!(:your_error, metadata: { http_status: 400 })\nrescue =\u003e e\n  puts e.metadata[:http_status] # Will return 400\nend\n```\n\n### I18n Interpolation\n\nYou can pass in parameter values to your localized error messages.\n\n```yaml\nen\n  errawr:\n  your_error:\n    message: \"My awesome error message is: %{error_message}\"\n```\n\n```ruby\nbegin\n  Errawr.error!(:your_error, error_message: 'You did it wrong!')\nrescue =\u003e e\n  puts e.message # Will return \"My awesome error message is: You did it wrong!\"\nend\n```\n\n### Overrides\n\nIt's possible to override metadata stored in a locale file both globally and\non a per use basis.\n\n```yaml\nen:\n  errawr:\n    your_error:\n      message: My awesome error message\n      metadata:\n        http_status: 400\n```\n\nThe ```#register!``` method will override the locale file.\n\n```ruby\nErrawr.register!(:your_error, message: 'Some other error message', metadata: { http_status: 403 })\nbegin\n  Errawr.error!(:your_error)\nrescue =\u003e e\n  puts e.message # =\u003e Will return \"Some other error message\"\n  puts e.metadata[:http_status] # =\u003e Will return 403\nend\n```\n\nThe ```#error!``` method will override both ```#register!``` and the locale file.\n\n```ruby\nErrawr.register!(:your_error, message: 'Some other error message', metadata: { http_status: 403 })\nbegin\n  Errawr.error!(:your_error, message: 'Yet another error message', metadata: { http_status: 404 })\nrescue =\u003e e\n  puts e.message # =\u003e Will return \"Yet another error message\"\n  puts e.metadata[:http_status] # =\u003e Will return 404\nend\n```\n\n### Custom Error Classes\n\nWant to write a custom error class? No problem!\n\n```ruby\nclass YourError \u003c Errawr::Error\n  def your_method\n     ...\n  end\nend\n\n# Register your error with your custom class\nErrawr.register!(:your_error, base_class: YourError)\n\n# Do something with it\nbegin\n  Errawr.error!(:your_error)\nrescue =\u003e e\n  e.your_method\nend\n```\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\n## Credits\n[![Sticksnleaves](http://sticksnleaves-wordpress.herokuapp.com/wp-content/themes/sticksnleaves/images/snl-logo-116x116.png)](http://www.sticksnleaves.com)\n\nErrawr is maintained and funded by [Sticksnleaves](http://www.sticksnleaves.com)\n\nThanks to all of our [contributors](https://github.com/anthonator/errawr/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonator%2Ferrawr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonator%2Ferrawr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonator%2Ferrawr/lists"}