Fauna v10 .NET/C# Driver
0.2.0-beta
Loading...
Searching...
No Matches
Fauna
Exceptions
ExceptionFactory.cs
Go to the documentation of this file.
1
using
System.Net;
2
using
Fauna.Mapping
;
3
4
namespace
Fauna.Exceptions
;
5
6
public
static
class
ExceptionFactory
7
{
8
public
static
Exception FromQueryFailure(
MappingContext
ctx,
QueryFailure
f)
9
{
10
var msg =
11
$
"{f.StatusCode} ({f.ErrorCode}): {f.Message}{(f.Summary is { Length: > 0 } ? "
\n---\n
" + f.Summary : "
")}"
;
12
13
return
f.ErrorCode
switch
14
{
15
"abort"
=>
new
AbortException
(msg, f, ctx),
16
"bad_gateway"
=>
new
BadGatewayException
(msg, f),
17
"contended_transaction"
=>
new
ContendedTransactionException
(msg, f),
18
"forbidden"
=>
new
ForbiddenException
(msg, f),
19
"internal_error"
=>
new
ServiceException
(msg, f),
20
"invalid_argument"
=>
new
QueryRuntimeException
(msg, f),
21
"invalid_query"
=>
new
QueryCheckException
(msg, f),
22
"invalid_request"
=>
new
InvalidRequestException
(msg, f),
23
"limit_exceeded"
=>
new
ThrottlingException
(msg, f),
24
"time_out"
=>
new
QueryTimeoutException
(msg, f),
25
"gateway_timeout"
=>
new
NetworkException
(msg, f.
StatusCode
, f.
Message
),
26
"unauthorized"
=>
new
UnauthorizedException
(msg, f),
27
28
_ =>
new
QueryRuntimeException
(msg, f)
29
};
30
}
31
32
33
public
static
Exception FromRawResponse(
string
body, HttpResponseMessage r)
34
{
35
if
(r.StatusCode is >= HttpStatusCode.OK and <= (HttpStatusCode)299)
36
{
37
// We should never get here, but if we do it's outside of the expected wire protocol.
38
return
new
ProtocolException
(
"Malformed response."
, r.StatusCode, body);
39
}
40
41
return
r.StatusCode
switch
42
{
43
HttpStatusCode.TooManyRequests =>
new
ThrottlingException
(
44
$
"{r.StatusCode}: {r.ReasonPhrase ?? "
Too many requests.
"}"
),
45
_ =>
new
FaunaException
($
"{r.StatusCode}: {r.ReasonPhrase}"
)
46
};
47
}
48
}
Fauna.Exceptions.AbortException
Represents an exception that occurs when the FQL abort function is called. This exception captures th...
Definition
ServiceException.cs:90
Fauna.Exceptions.BadGatewayException
Represents an exception thrown for a bad gateway. Corresponds to the 'bad_gateway' error code in Faun...
Definition
ServiceException.cs:153
Fauna.Exceptions.ContendedTransactionException
Represents an exception that occurs when a transaction is aborted due to concurrent modification....
Definition
ServiceException.cs:251
Fauna.Exceptions.FaunaException
Represents the base exception class for all exceptions specific to Fauna interactions.
Definition
FaunaException.cs:9
Fauna.Exceptions.ForbiddenException
Represents an exception thrown when access to a resource is not allowed. Corresponds to the 'forbidde...
Definition
ServiceException.cs:164
Fauna.Exceptions.InvalidRequestException
Represents exceptions caused by invalid requests to Fauna.
Definition
ServiceException.cs:240
Fauna.Exceptions.NetworkException
Definition
ServiceException.cs:261
Fauna.Exceptions.ProtocolException
Represents exceptions when a response does not match the wire protocol.
Definition
ProtocolException.cs:9
Fauna.Exceptions.QueryCheckException
Represents exceptions thrown when the query has syntax errors.
Definition
ServiceException.cs:205
Fauna.Exceptions.QueryRuntimeException
Represents exceptions thrown when the query fails at runtime.
Definition
ServiceException.cs:215
Fauna.Exceptions.QueryTimeoutException
Represents exceptions thrown when the query execution time exceeds the specified or default timeout p...
Definition
ServiceException.cs:195
Fauna.Exceptions.ServiceException
Represents an exception related to Fauna service errors, particularly for query failures.
Definition
ServiceException.cs:16
Fauna.Exceptions.ThrottlingException
Represents an exception that indicates some capacity limit was exceeded and thus the request could no...
Definition
ServiceException.cs:226
Fauna.Exceptions.UnauthorizedException
Represents an exception thrown when there is an authorization error in Fauna. Corresponds to the 'una...
Definition
ServiceException.cs:175
Fauna.Mapping.MappingContext
A class representing the mapping context to be used during serialization and deserialization.
Definition
MappingContext.cs:9
Fauna.QueryFailure
Represents a failed query response.
Definition
QueryResponse.cs:160
Fauna.QueryFailure.Message
string Message
Definition
QueryResponse.cs:163
Fauna.QueryFailure.StatusCode
HttpStatusCode StatusCode
Definition
QueryResponse.cs:161
Fauna.Exceptions
Definition
ExceptionFactory.cs:4
Fauna.Mapping
Definition
Attributes.cs:1
Generated by
1.12.0