Fauna v10 .NET/C# Driver 1.0.1
 
Loading...
Searching...
No Matches
AbortException.cs
Go to the documentation of this file.
1using Fauna.Core;
2using Fauna.Mapping;
4
6
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}
Represents a failed query response.
object? Abort
The abort object, if any. Only present for the abort error code.
Represents an exception that occurs when the FQL abort function is called. This exception captures th...
T? GetData< T >()
Retrieves the deserialized data associated with the abort operation as a specific type.
object? GetData()
Retrieves the deserialized data associated with the abort operation as an object.
AbortException(string message, QueryFailure failure, MappingContext ctx)
Initializes a new instance of the AbortException class with a specified error message and query failu...
Represents an exception related to Fauna service errors, particularly for query failures.
A class representing the mapping context to be used during serialization and deserialization.
A generic interface that defines serialize and deserialize behavior for a specific type,...
Represents a reader that provides fast, non-cached, forward-only access to serialized data.