Skip to content

Commit 293a1d1

Browse files
DOC-5886 improved C# error handling page
1 parent 8ebfc68 commit 293a1d1

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ var db = muxer.GetDatabase();
4848
try {
4949
var result = db.StringGet("key");
5050
} catch (RedisCommandException) {
51-
// This indicates a bug in our code
51+
// This indicates a bug in the code, such as using
52+
// StringGet on a list key.
5253
throw;
5354
}
5455
```
@@ -62,21 +63,18 @@ for a full description):
6263
```csharp
6364
try {
6465
var cachedValue = db.StringGet(key);
65-
if (cachedValue.HasValue) {
66-
return cachedValue.ToString();
67-
}
66+
return cachedValue.ToString();
6867
} catch (RedisConnectionException) {
6968
logger.LogWarning("Cache unavailable, using database");
69+
70+
// Fallback to database
7071
return database.Get(key);
7172
}
72-
73-
// Fallback to database
74-
return database.Get(key);
7573
```
7674

7775
### Pattern 3: Retry with backoff
7876

79-
Retry on temporary errors like timeouts (see
77+
Retry on temporary errors such as timeouts (see
8078
[Pattern 3: Retry with backoff]({{< relref "/develop/clients/error-handling#pattern-3-retry-with-backoff" >}})
8179
for a full description):
8280

@@ -98,6 +96,9 @@ for (int attempt = 0; attempt < maxRetries; attempt++) {
9896
}
9997
```
10098

99+
See also [Timeouts]({{< relref "/develop/clients/dotnet/produsage#timeouts" >}})
100+
for more information on configuring timeouts in NRedisStack.
101+
101102
### Pattern 4: Log and continue
102103

103104
Log non-critical errors and continue (see
@@ -115,7 +116,8 @@ try {
115116

116117
## Async error handling
117118

118-
If you're using async methods, error handling works the same way with `async`/`await`:
119+
Error handling works the usual way with `async`/`await`, as shown in the
120+
example below:
119121

120122
```csharp
121123
using NRedisStack;
@@ -143,5 +145,3 @@ async Task<string> GetWithFallbackAsync(string key) {
143145

144146
- [Error handling]({{< relref "/develop/clients/error-handling" >}})
145147
- [Production usage]({{< relref "/develop/clients/dotnet/produsage" >}})
146-
- [Connection pooling]({{< relref "/develop/clients/pools-and-muxing" >}})
147-

content/develop/clients/error-handling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ Command errors occur when Redis receives an invalid or malformed command. These
5555
**Common causes:**
5656
- Typo in command name
5757
- Wrong number of arguments
58-
- Invalid argument types (for example, supplying a [string]({{< relref "/develop/
59-
data-types/strings" >}}) key to a [list]({{< relref "/develop/data-types/lists"
60-
>}}) command))
58+
- Invalid argument types (for example, supplying a
59+
[string]({{< relref "/develop/data-types/strings" >}}) key to a
60+
[list]({{< relref "/develop/data-types/lists" >}}) command))
6161
- Using a command that doesn't exist in your Redis version
6262

6363
**Examples:**

0 commit comments

Comments
 (0)