-
Notifications
You must be signed in to change notification settings - Fork 41
/
errors.dart
131 lines (110 loc) · 3.26 KB
/
errors.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import 'package:segment_analytics/analytics.dart';
import 'package:segment_analytics/logger.dart';
class StorageUnableToCreate implements Exception {
final String msg;
StorageUnableToCreate(this.msg);
@override
String toString() => "Unable to create storage: $msg";
}
class StorageUnableToWrite implements Exception {
final String msg;
StorageUnableToWrite(this.msg);
@override
String toString() => "Unable to write to storage: $msg";
}
class StorageUnableToRename implements Exception {
final String msg;
StorageUnableToRename(this.msg);
@override
String toString() => "Unable to rename storage: $msg";
}
class StorageUnableToOpen implements Exception {
final String msg;
StorageUnableToOpen(this.msg);
@override
String toString() => "Unable to open storage: $msg";
}
class StorageUnableToClose implements Exception {
final String msg;
StorageUnableToClose(this.msg);
@override
String toString() => "Unable to close storage: $msg";
}
class StorageInvalid implements Exception {
final String msg;
StorageInvalid(this.msg);
@override
String toString() => "Invalide storage: $msg";
}
class StorageUnknown implements Exception {
final String msg;
StorageUnknown(this.msg);
@override
String toString() => "Unknown storage error: $msg";
}
class NetworkUnexpectedHTTPCode implements Exception {
final int code;
NetworkUnexpectedHTTPCode(this.code);
@override
String toString() => "Unexpected HTTP response code: $code";
}
class NetworkServerLimited implements Exception {
final int code;
NetworkServerLimited(this.code);
@override
String toString() => "HTTP server limited: $code";
}
class NetworkServerRejected implements Exception {
final int code;
NetworkServerRejected(this.code);
@override
String toString() => "HTTP server rejected request: $code";
}
class NetworkUnknown implements Exception {
final String msg;
NetworkUnknown(this.msg);
@override
String toString() => "Unknown network error: $msg";
}
class NetworkInvalidData implements Exception {
@override
String toString() => "Invalid network data";
}
class JSONUnableToDeserialize implements Exception {
final String msg;
final String type;
JSONUnableToDeserialize(this.type, this.msg);
@override
String toString() => "Unable to deserialize JSON to $type: $msg";
}
class PluginError implements Exception {
final String msg;
final Object inner;
PluginError(this.msg, this.inner);
}
class InconsistentStateError implements Exception {
final String key;
InconsistentStateError(this.key);
@override
String toString() => "Store for $key is in an inconsistent state";
}
class PlatformNotSupportedError extends Error {
final String message = 'Current platform is not supported';
}
class ErrorLoadingStorage implements Exception {
final Object innerError;
ErrorLoadingStorage(this.innerError);
@override
String toString() => "Error loading storage: $innerError";
}
void reportInternalError(Exception error,
{bool fatal = false, Analytics? analytics}) {
log("An internal error occurred: $error", kind: LogFilterKind.error);
final errorHandler = analytics?.state.configuration.state.errorHandler;
if (errorHandler != null) {
errorHandler(error);
}
if (fatal) {
AssertionError("A critical error occurred: $error");
}
}