10public static class ExceptionHandler
21 $
"{f.StatusCode} ({f.ErrorCode}): {f.Message}{(f.Summary is { Length: > 0 } ? "\n---\n
" + f.Summary : "")}";
23 return f.ErrorCode
switch
25 "abort" =>
new AbortException(msg, f, ctx),
26 "bad_gateway" =>
new BadGatewayException(msg, f),
27 "contended_transaction" =>
new ContendedTransactionException(msg, f),
28 "forbidden" =>
new AuthorizationException(msg, f),
29 "internal_error" =>
new ServiceException(msg, f),
30 "invalid_query" =>
new QueryCheckException(msg, f),
31 "invalid_request" =>
new InvalidRequestException(msg, f),
32 "limit_exceeded" =>
new ThrottlingException(msg, f),
33 "time_out" =>
new QueryTimeoutException(msg, f),
35 "unauthorized" =>
new AuthenticationException(msg, f),
36 "constraint_failure" =>
new ConstraintFailureException(msg, f),
38 _ =>
new QueryRuntimeException(msg, f)
49 public static Exception FromRawResponse(
string body, HttpResponseMessage r)
51 if (r.StatusCode is >= HttpStatusCode.OK and <= (HttpStatusCode)299)
54 return new ProtocolException(
"Malformed response.", r.StatusCode, body);
57 return r.StatusCode
switch
59 HttpStatusCode.TooManyRequests =>
new ThrottlingException(
60 $
"{r.StatusCode}: {r.ReasonPhrase ?? "Too many requests.
"}"),
61 _ =>
new FaunaException($
"{r.StatusCode}: {r.ReasonPhrase}")
Represents a failed query response.
string Message
The query failure message.
HttpStatusCode StatusCode
The HTTP status code.
A class representing the mapping context to be used during serialization and deserialization.