diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2014-12-17 09:03:06 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2014-12-17 09:03:06 +0000 |
commit | 2ec6e0c7f99466286e006ab68ff8188e3fbea0f4 (patch) | |
tree | 35e8be011e76fb3eb35b5fa07eedb00a2d51fbff /README.md | |
parent | d7f1e3f899f86633bc9d287b39eb56957ca143af (diff) | |
download | slop-2ec6e0c7f99466286e006ab68ff8188e3fbea0f4.tar.gz |
Add errors section to readme
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -145,3 +145,28 @@ end p opts[:files] #=> ["/full/path/foo.txt", "/full/path/bar.rb"] ``` + +Errors +------ + +Slop will raise errors for the following: + +* An option used without an argument when it expects one: `Slop::MissingArgument` +* An option used that Slop doesn't know about: `Slop::UnknownOption` + +These errors inherit from `Slop::Error`, so you can rescue them all. +Alternatively you can suppress these errors with the `suppress_errors` config +option: + +```ruby +opts = Slop.parse suppress_errors: true do + o.string '-name' +end + +# or per option: + +opts = Slop.parse do + o.string '-host', suppress_errors: true + o.int '-port' +end +``` |