Skip to content

Commit 60162f0

Browse files
DOC-5880 last (maybe) fixes to client-specific error pages
1 parent afdd9b0 commit 60162f0

File tree

3 files changed

+13
-39
lines changed

3 files changed

+13
-39
lines changed

content/develop/clients/go/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ go-redis:
4545

4646
### Pattern 1: Fail fast
4747

48-
Return the error immediately (see
48+
Return the error immediately if it represents an unrecoverable situation (see
4949
[Pattern 1: Fail fast]({{< relref "/develop/clients/error-handling#pattern-1-fail-fast" >}})
5050
for a full description):
5151

content/develop/clients/nodejs/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ below show how to implement these patterns in node-redis:
9292

9393
### Pattern 1: Fail fast
9494

95-
Catch specific errors and re-throw them (see
95+
Catch specific errors that represent unrecoverable errors and re-throw them (see
9696
[Pattern 1: Fail fast]({{< relref "/develop/clients/error-handling#pattern-1-fail-fast" >}})
9797
for a full description).
9898

content/develop/clients/redis-py/error-handling.md

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Error handling
33
description: Learn how to handle errors when using redis-py
44
linkTitle: Error handling
5-
weight: 50
5+
weight: 65
66
---
77

88
redis-py uses **exceptions** to signal errors. The redis-py documentation mainly
@@ -53,7 +53,7 @@ redis-py:
5353

5454
### Pattern 1: Fail fast
5555

56-
Catch specific exceptions and re-raise them (see
56+
Catch specific exceptions that represent unrecoverable errors and re-raise them (see
5757
[Pattern 1: Fail fast]({{< relref "/develop/clients/error-handling#pattern-1-fail-fast" >}})
5858
for a full description):
5959

@@ -65,7 +65,7 @@ r = redis.Redis()
6565
try:
6666
result = r.get(key)
6767
except redis.ResponseError:
68-
# This indicates a bug in our code
68+
# This indicates a bug in the code
6969
raise
7070
```
7171

@@ -91,24 +91,12 @@ return database.get(key)
9191

9292
Retry on temporary errors like timeouts (see
9393
[Pattern 3: Retry with backoff]({{< relref "/develop/clients/error-handling#pattern-3-retry-with-backoff" >}})
94-
for a full description):
95-
96-
```python
97-
import time
98-
99-
max_retries = 3
100-
retry_delay = 0.1
101-
102-
for attempt in range(max_retries):
103-
try:
104-
return r.get(key)
105-
except redis.TimeoutError:
106-
if attempt < max_retries - 1:
107-
time.sleep(retry_delay)
108-
retry_delay *= 2 # Exponential backoff
109-
else:
110-
raise
111-
```
94+
for a full description). redis-py has built-in retry logic
95+
which is highly configurable. You can customize the retry strategy
96+
(or supply your own custom strategy) and you can also specify which errors
97+
should be retried. See
98+
[Production usage]({{< relref "/develop/clients/redis-py/produsage#retries" >}})
99+
for more information.
112100

113101
### Pattern 4: Log and continue
114102

@@ -126,7 +114,8 @@ except redis.ConnectionError:
126114

127115
## Async error handling
128116

129-
If you're using `redis.asyncio`, error handling works the same way, but with `async`/`await`:
117+
Error handling works the usual way when you use `async`/`await`,
118+
as shown in the example below:
130119

131120
```python
132121
import redis.asyncio as redis
@@ -142,22 +131,7 @@ async def get_with_fallback(key):
142131
await r.close()
143132
```
144133

145-
## Connection pool errors
146-
147-
Connection pool exhaustion raises a `redis.ConnectionError`. Monitor pool usage
148-
and adjust the pool size if necessary:
149-
150-
```python
151-
pool = redis.ConnectionPool(
152-
host="localhost",
153-
port=6379,
154-
max_connections=50 # Adjust based on your needs
155-
)
156-
r = redis.Redis(connection_pool=pool)
157-
```
158-
159134
## See also
160135

161136
- [Error handling]({{< relref "/develop/clients/error-handling" >}})
162137
- [Production usage]({{< relref "/develop/clients/redis-py/produsage" >}})
163-
- [Connection pooling]({{< relref "/develop/clients/pools-and-muxing" >}})

0 commit comments

Comments
 (0)