Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
3397dcdc
Commit
3397dcdc
authored
Mar 11, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: ExceptionFactory
parent
f7a4110e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
ExceptionFactory.cs
StackExchange.Redis/StackExchange/Redis/ExceptionFactory.cs
+20
-19
No files found.
StackExchange.Redis/StackExchange/Redis/ExceptionFactory.cs
View file @
3397dcdc
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Globalization
;
using
System.Text
;
namespace
StackExchange.Redis
{
internal
static
class
ExceptionFactory
{
const
string
DataCommandKey
=
"redis-command"
,
DataServerKey
=
"redis-server"
,
DataServerEndpoint
=
"server-endpoint"
,
DataConnectionState
=
"connection-state"
,
DataLastFailure
=
"last-failure"
,
DataLastInnerException
=
"last-innerexception"
,
DataSentStatusKey
=
"request-sent-status"
;
private
const
string
DataCommandKey
=
"redis-command"
,
DataSentStatusKey
=
"request-sent-status"
,
DataServerKey
=
"redis-server"
;
internal
static
Exception
AdminModeNotEnabled
(
bool
includeDetail
,
RedisCommand
command
,
Message
message
,
ServerEndPoint
server
)
{
...
...
@@ -24,6 +18,7 @@ internal static Exception AdminModeNotEnabled(bool includeDetail, RedisCommand c
if
(
includeDetail
)
AddDetail
(
ex
,
message
,
server
,
s
);
return
ex
;
}
internal
static
Exception
CommandDisabled
(
bool
includeDetail
,
RedisCommand
command
,
Message
message
,
ServerEndPoint
server
)
{
string
s
=
GetLabel
(
includeDetail
,
command
,
message
);
...
...
@@ -31,6 +26,7 @@ internal static Exception CommandDisabled(bool includeDetail, RedisCommand comma
if
(
includeDetail
)
AddDetail
(
ex
,
message
,
server
,
s
);
return
ex
;
}
internal
static
Exception
TooManyArgs
(
bool
includeDetail
,
string
command
,
Message
message
,
ServerEndPoint
server
,
int
required
)
{
string
s
=
GetLabel
(
includeDetail
,
command
,
message
);
...
...
@@ -38,6 +34,7 @@ internal static Exception TooManyArgs(bool includeDetail, string command, Messag
if
(
includeDetail
)
AddDetail
(
ex
,
message
,
server
,
s
);
return
ex
;
}
internal
static
Exception
CommandDisabled
(
bool
includeDetail
,
string
command
,
Message
message
,
ServerEndPoint
server
)
{
string
s
=
GetLabel
(
includeDetail
,
command
,
message
);
...
...
@@ -106,7 +103,7 @@ internal static string GetInnerMostExceptionMessage(Exception e)
return
e
.
Message
;
}
}
internal
static
Exception
NoConnectionAvailable
(
bool
includeDetail
,
bool
includePerformanceCounters
,
RedisCommand
command
,
Message
message
,
ServerEndPoint
server
,
ServerEndPoint
[]
serverSnapshot
)
{
string
commandLabel
=
GetLabel
(
includeDetail
,
command
,
message
);
...
...
@@ -135,7 +132,7 @@ internal static Exception NoConnectionAvailable(bool includeDetail, bool include
#endif
var
ex
=
new
RedisConnectionException
(
ConnectionFailureType
.
UnableToResolvePhysicalConnection
,
exceptionmessage
.
ToString
(),
innerException
,
message
?.
Status
??
CommandStatus
.
Unknown
);
if
(
includeDetail
)
{
AddDetail
(
ex
,
message
,
server
,
commandLabel
);
...
...
@@ -145,7 +142,7 @@ internal static Exception NoConnectionAvailable(bool includeDetail, bool include
internal
static
Exception
PopulateInnerExceptions
(
ServerEndPoint
[]
serverSnapshot
)
{
List
<
Exception
>
innerExceptions
=
new
List
<
Exception
>();
var
innerExceptions
=
new
List
<
Exception
>();
if
(
serverSnapshot
!=
null
)
{
if
(
serverSnapshot
.
Length
>
0
&&
serverSnapshot
[
0
].
Multiplexer
.
LastException
!=
null
)
...
...
@@ -180,11 +177,11 @@ internal static Exception NotSupported(bool includeDetail, RedisCommand command)
if
(
includeDetail
)
AddDetail
(
ex
,
null
,
null
,
s
);
return
ex
;
}
internal
static
Exception
NoCursor
(
RedisCommand
command
)
{
string
s
=
GetLabel
(
false
,
command
,
null
);
var
ex
=
new
RedisCommandException
(
"Command cannot be used with a cursor: "
+
s
);
return
ex
;
return
new
RedisCommandException
(
"Command cannot be used with a cursor: "
+
s
);
}
internal
static
Exception
Timeout
(
bool
includeDetail
,
string
errorMessage
,
Message
message
,
ServerEndPoint
server
)
...
...
@@ -203,17 +200,21 @@ private static void AddDetail(Exception exception, Message message, ServerEndPoi
exception
.
Data
.
Add
(
DataCommandKey
,
message
.
CommandAndKey
);
exception
.
Data
.
Add
(
DataSentStatusKey
,
message
.
Status
);
}
else
if
(
label
!=
null
)
exception
.
Data
.
Add
(
DataCommandKey
,
label
);
else
if
(
label
!=
null
)
{
exception
.
Data
.
Add
(
DataCommandKey
,
label
);
}
if
(
server
!=
null
)
exception
.
Data
.
Add
(
DataServerKey
,
Format
.
ToString
(
server
.
EndPoint
));
}
}
static
string
GetLabel
(
bool
includeDetail
,
RedisCommand
command
,
Message
message
)
private
static
string
GetLabel
(
bool
includeDetail
,
RedisCommand
command
,
Message
message
)
{
return
message
==
null
?
command
.
ToString
()
:
(
includeDetail
?
message
.
CommandAndKey
:
message
.
Command
.
ToString
());
}
static
string
GetLabel
(
bool
includeDetail
,
string
command
,
Message
message
)
private
static
string
GetLabel
(
bool
includeDetail
,
string
command
,
Message
message
)
{
return
message
==
null
?
command
:
(
includeDetail
?
message
.
CommandAndKey
:
message
.
Command
.
ToString
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment