# Viator Sometimes exceptions are not what I want. Sometimes they are ugly. Sometimes they are overkill. Throwing exceptions seems wrong for correct and expected behaviour. Sometimes I want: ```ruby result = User.create('pogs_for_life', 'password', 'pogsandhorses@geocities.com') if result.success? do_something result.value else result.errors.each { |e| do_something_else(e) } end ``` This can be especially nice when you are using the builder pattern. Other solutions I have seen are overly-complicated, often using monads, which I do not think fit Ruby very nicely. I find myself rewriting variations of this again and again, so I have made a gem. Viator is extremely simple, suspiciously so. ## Installation In your Gemfile: ```ruby gem 'viator' ``` or on the console: $ gem install viator ## Usage ```ruby eh = Viator.new # create a new error handler eh.success? # true eh.failure? # false eh.count # 0 eh.errors # [] eh.report 'argument invalid!' eh.success? # false eh.count # 1 eh.errors # ['argument invalid!'] eh.reset eh.success? # true eh.value = 'arbitrary data' eh.value # returns 'nil' if eh.failure? ``` ## Contributing Bug reports and pull requests are welcome on Bitbucket at https://bitbucket.org/surdegg/viator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). This project was created by [Surd Egg](https://surdegg.com). News and updates can be found [here](https://sananab.ca). ## Code of Conduct Everyone interacting in the Viator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/viator/blob/master/CODE_OF_CONDUCT.md).