https://github.com/isuke/ruby_friendly_error
Make to ruby error messages friendly.
https://github.com/isuke/ruby_friendly_error
ruby
Last synced: about 1 year ago
JSON representation
Make to ruby error messages friendly.
- Host: GitHub
- URL: https://github.com/isuke/ruby_friendly_error
- Owner: isuke
- License: mit
- Created: 2018-08-15T03:44:21.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-20T07:04:53.000Z (over 7 years ago)
- Last Synced: 2025-03-06T11:48:12.502Z (over 1 year ago)
- Topics: ruby
- Language: Ruby
- Homepage: https://rubygems.org/gems/ruby_friendly_error
- Size: 673 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.adoc
Awesome Lists containing this project
README
:chapter-label:
:icons: font
:lang: en
:sectanchors:
:sectlinks:
:sectnums:
:source-highlighter: highlightjs
:toc: left
:toclevels: 2
= RubyFriendlyError image:https://img.shields.io/badge/ruby-2.4.5-cc342d.svg["ruby 2.4.5", link="https://www.ruby-lang.org/en/news/2018/10/17/ruby-2-4-5-released/"] image:https://img.shields.io/badge/ruby-2.5.3-cc342d.svg["ruby 2.5.3", link="https://www.ruby-lang.org/en/news/2018/10/18/ruby-2-5-3-released/"]
image:https://travis-ci.org/isuke/ruby_friendly_error.svg?branch=master["Build Status", link="https://travis-ci.org/isuke/ruby_friendly_error"]
== Installation and Usage
Add this line to your application's Gemfile:
```ruby
gem 'ruby_friendly_error'
```
```sh
$ bundle exec ruby_friendly_error your.rb
```
== Samples
=== miss spell
[source,ruby]
.sample.rb
----
# frozen_string_literal: true
def hoge prayer_life = 100 , player_lifee = 200
puts 'hoge' if player_life > 0
end
hoge
----
```sh
$ bundle exec ruby_friendly_error sample.rb
```
image:https://raw.githubusercontent.com/isuke/ruby_friendly_error/images/name_error_with_did_you_mean.png["name_error_with_did_you_mean", caption="output"]
=== miss args num
[source,ruby]
.sample.rb
----
# frozen_string_literal: true
def hoge arg1, arg2 = 'foobar'
puts arg1
puts arg2
end
hoge 'piyo', 'fuga', 'what!?'
----
```sh
$ bundle exec ruby_friendly_error sample.rb
```
image:https://raw.githubusercontent.com/isuke/ruby_friendly_error/images/wrong_number_of_arguments_error.png["wrong_number_of_arguments_error", caption="output"]
== Options
[cols="1,2,1,1", options="header"]
|===
| key
| description
| values
| default
| RUBY_FRIENDLY_ERROR_LANG
| message language.
| en, ja
| en
| RUBY_FRIENDLY_ERROR_WINDOW
| display error lines window size.
| Integer
| 2
|===
=== RUBY_FRIENDLY_ERROR_LANG
```sh
$ RUBY_FRIENDLY_ERROR_LANG=ja bundle exec ruby_friendly_error sample.rb
```
image:https://raw.githubusercontent.com/isuke/ruby_friendly_error/images/wrong_number_of_arguments_error_ja.png["wrong_number_of_arguments_error_ja", caption="output"]
== Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to https://rubygems.org[rubygems.org].
== Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/isuke/ruby_friendly_error. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the http://contributor-covenant.org[Contributor Covenant] code of conduct.
== License
The gem is available as open source under the terms of the https://opensource.org/licenses/MIT[MIT License].
== Code of Conduct
Everyone interacting in the RubyFriendlyError project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/isuke/ruby_friendly_error/blob/master/CODE_OF_CONDUCT.adoc).