Skip to content

Commit 178c661

Browse files
author
Erik DeBill
committed
add a quick note about error handling to the README [ci-skip]
1 parent 7c4a954 commit 178c661

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
@@ -158,6 +158,26 @@ end
158158
# => 1
159159
```
160160

161+
## Error Handling
162+
163+
In general, if something goes wrong you'll get an exception. For example, if
164+
it can't connect to the server a `Redis::CannotConnectError` error will be raised.
165+
166+
```ruby
167+
begin
168+
redis.ping
169+
rescue Exception => e
170+
e.inspect
171+
# => #<Redis::CannotConnectError: Timed out connecting to Redis on 10.0.1.1:6380>
172+
173+
e.message
174+
# => Timed out connecting to Redis on 10.0.1.1:6380
175+
end
176+
```
177+
178+
See lib/redis/errors.rb for information about what exceptions are possible.
179+
180+
161181
## Expert-Mode Options
162182

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

0 commit comments

Comments
 (0)