Skip to content

Commit d43b06e

Browse files
committed
Merge pull request #451 from edebill/master
add a quick note about error handling to the README
2 parents 1ee96ae + 178c661 commit d43b06e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,26 @@ end
187187
# => 1
188188
```
189189

190+
## Error Handling
191+
192+
In general, if something goes wrong you'll get an exception. For example, if
193+
it can't connect to the server a `Redis::CannotConnectError` error will be raised.
194+
195+
```ruby
196+
begin
197+
redis.ping
198+
rescue Exception => e
199+
e.inspect
200+
# => #<Redis::CannotConnectError: Timed out connecting to Redis on 10.0.1.1:6380>
201+
202+
e.message
203+
# => Timed out connecting to Redis on 10.0.1.1:6380
204+
end
205+
```
206+
207+
See lib/redis/errors.rb for information about what exceptions are possible.
208+
209+
190210
## Expert-Mode Options
191211

192212
- `inherit_socket: true`: disable safety check that prevents a forked child

0 commit comments

Comments
 (0)