-
Notifications
You must be signed in to change notification settings - Fork 118
/
exceptions.dart
98 lines (82 loc) · 2.96 KB
/
exceptions.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import "package:gql_exec/gql_exec.dart";
import "package:meta/meta.dart";
/// A base class for exceptions thrown by links
@immutable
abstract class LinkException implements Exception {
/// The original exception causing this exception
final Object? originalException;
final StackTrace? originalStackTrace;
const LinkException(
this.originalException,
this.originalStackTrace,
);
@override
String toString() => "LinkException($originalException, $originalStackTrace)";
}
/// Exception occurring when a terminating link
/// tries to serialize the request
@immutable
class RequestFormatException extends LinkException {
/// The request being serialized when the error occurred
final Request request;
const RequestFormatException({
required this.request,
Object? originalException,
StackTrace? originalStackTrace,
}) : super(originalException, originalStackTrace);
@override
String toString() =>
"RequestFormatException(originalException: $originalException, originalStackTrace: $originalStackTrace, request: $request)";
}
/// Exception occurring when a terminating link
/// tries to parse the response
@immutable
class ResponseFormatException extends LinkException {
const ResponseFormatException({
Object? originalException,
StackTrace? originalStackTrace,
}) : super(originalException, originalStackTrace);
@override
String toString() =>
"ResponseFormatException(originalException: $originalException, originalStackTrace: $originalStackTrace)";
}
/// Exception occurring when reading from the context
@immutable
class ContextReadException extends LinkException {
const ContextReadException({
Object? originalException,
StackTrace? originalStackTrace,
}) : super(originalException, originalStackTrace);
@override
String toString() =>
"ContextReadException(originalException: $originalException, originalStackTrace: $originalStackTrace)";
}
/// Exception occurring when writing to the context
@immutable
class ContextWriteException extends LinkException {
const ContextWriteException({
Object? originalException,
StackTrace? originalStackTrace,
}) : super(originalException, originalStackTrace);
@override
String toString() =>
"ContextWriteException(originalException: $originalException, originalStackTrace: $originalStackTrace)";
}
/// Exception occurring when network fails
/// or parsed response is missing both `data` and `errors`
@immutable
class ServerException extends LinkException {
/// The parsed response
final Response? parsedResponse;
/// The status code of the request, if available
final int? statusCode;
const ServerException({
this.parsedResponse,
this.statusCode,
Object? originalException,
StackTrace? originalStackTrace,
}) : super(originalException, originalStackTrace);
@override
String toString() =>
"ServerException(originalException: $originalException, originalStackTrace: $originalStackTrace, parsedResponse: $parsedResponse)";
}