summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2014-12-17 09:03:06 +0000
committerLee Jarvis <ljjarvis@gmail.com>2014-12-17 09:03:06 +0000
commit2ec6e0c7f99466286e006ab68ff8188e3fbea0f4 (patch)
tree35e8be011e76fb3eb35b5fa07eedb00a2d51fbff /README.md
parentd7f1e3f899f86633bc9d287b39eb56957ca143af (diff)
downloadslop-2ec6e0c7f99466286e006ab68ff8188e3fbea0f4.tar.gz
Add errors section to readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/README.md b/README.md
index 4666807..f761338 100644
--- a/README.md
+++ b/README.md
@@ -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
+```