Fauna v10 .NET/C# Driver
1.0.1
Loading...
Searching...
No Matches
repo.git
Fauna
Exceptions
AbortException.cs
Go to the documentation of this file.
1
using
Fauna.Core
;
2
using
Fauna.Mapping
;
3
using
Fauna.Serialization
;
4
5
namespace
Fauna.Exceptions
;
6
11
public
class
AbortException
:
ServiceException
12
{
13
private
readonly
MappingContext
_ctx;
14
private
readonly Dictionary<Type, object?> _cache =
new
();
15
private
readonly
object
? _abortRaw;
16
17
24
public
AbortException
(
string
message,
QueryFailure
failure,
MappingContext
ctx)
25
: base(message, failure)
26
{
27
_ctx = ctx;
28
_abortRaw = failure.
Abort
;
29
}
30
35
public
object
?
GetData
() =>
GetData
(Serializer.Dynamic);
36
42
public
T?
GetData<T>
() where T : notnull =>
GetData
(Serializer.Generate<T>(_ctx));
43
50
public T?
GetData
<T>(
ISerializer
<T> serializer)
51
{
52
var typeKey = typeof(T);
53
if
(_cache.TryGetValue(typeKey, out var cachedData))
return
(T?)cachedData;
54
55
if
(_abortRaw ==
null
)
return
(T?)cachedData;
56
57
var abortDataString = _abortRaw.ToString();
58
if
(
string
.IsNullOrEmpty(abortDataString))
return
(T?)cachedData;
59
60
// TODO(matt) pull from context
61
var reader =
new
Utf8FaunaReader
(abortDataString);
62
reader.Read();
63
64
var deserializedResult = serializer.Deserialize(_ctx, ref reader);
65
_cache[typeKey] = deserializedResult;
66
return
deserializedResult;
67
}
68
}
Fauna.Core.QueryFailure
Represents a failed query response.
Definition
QueryResponse.cs:164
Fauna.Core.QueryFailure.Abort
object? Abort
The abort object, if any. Only present for the abort error code.
Definition
QueryResponse.cs:184
Fauna.Exceptions.AbortException
Represents an exception that occurs when the FQL abort function is called. This exception captures th...
Definition
AbortException.cs:12
Fauna.Exceptions.AbortException.GetData< T >
T? GetData< T >()
Retrieves the deserialized data associated with the abort operation as a specific type.
Fauna.Exceptions.AbortException.GetData
object? GetData()
Retrieves the deserialized data associated with the abort operation as an object.
Fauna.Exceptions.AbortException.AbortException
AbortException(string message, QueryFailure failure, MappingContext ctx)
Initializes a new instance of the AbortException class with a specified error message and query failu...
Definition
AbortException.cs:24
Fauna.Exceptions.ServiceException
Represents an exception related to Fauna service errors, particularly for query failures.
Definition
ServiceException.cs:10
Fauna.Mapping.MappingContext
A class representing the mapping context to be used during serialization and deserialization.
Definition
MappingContext.cs:10
Fauna.Serialization.ISerializer
A generic interface that defines serialize and deserialize behavior for a specific type,...
Definition
ISerializer.cs:11
Fauna.Core
Definition
Connection.cs:13
Fauna.Exceptions
Definition
AbortException.cs:5
Fauna.Mapping
Definition
Attributes.cs:1
Fauna.Serialization
Definition
BaseRefSerializer.cs:5
Fauna.Serialization.Utf8FaunaReader
Represents a reader that provides fast, non-cached, forward-only access to serialized data.
Definition
Utf8FaunaReader.cs:14
Generated by
1.9.8