This repository was archived by the owner on Feb 13, 2024. It is now read-only.
File tree 4 files changed +70
-0
lines changed
4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -1061,6 +1061,41 @@ error Context::displayError(const error &err) {
1061
1061
return UI ()->DisplayError (err);
1062
1062
}
1063
1063
1064
+ error Context::reportError (const Error &err) {
1065
+ /* TODO
1066
+ if ((err.find(kUnauthorizedError) != std::string::npos)) {
1067
+ if (user_) {
1068
+ setUser(nullptr);
1069
+ }
1070
+ }
1071
+ */
1072
+ /* TODO
1073
+ if (err.find(kUnsupportedAppError) != std::string::npos) {
1074
+ urls::SetImATeapot(true);
1075
+ } else {
1076
+ urls::SetImATeapot(false);
1077
+ }
1078
+ */
1079
+ /* TODO
1080
+ if (user_ && (err.find(kRequestIsNotPossible) != std::string::npos
1081
+ || (err.find(kForbiddenError) != std::string::npos))) {
1082
+ error err = pullWorkspaces();
1083
+ if (err != noError) {
1084
+ // Check for missing WS error and
1085
+ if (err.find(kMissingWS) != std::string::npos) {
1086
+ overlay_visible_ = true;
1087
+ UI()->DisplayWSError();
1088
+ return noError;
1089
+ }
1090
+ }
1091
+ }
1092
+ */
1093
+
1094
+
1095
+
1096
+ return UI ()->DisplayError (err);
1097
+ }
1098
+
1064
1099
int Context::nextSyncIntervalSeconds () const {
1065
1100
int n = static_cast <int >(Random::next (kSyncIntervalRangeSeconds )) + kSyncIntervalRangeSeconds ;
1066
1101
logger.trace (" Next autosync in " , n, " seconds" );
Original file line number Diff line number Diff line change @@ -671,6 +671,7 @@ class TOGGL_INTERNAL_EXPORT Context : public TimelineDatasource {
671
671
void updateUI (const UIElements &elements);
672
672
673
673
error displayError (const error &err);
674
+ error reportError (const Error &err);
674
675
675
676
void scheduleSync ();
676
677
Original file line number Diff line number Diff line change @@ -180,6 +180,39 @@ error GUI::DisplayError(const error &err) {
180
180
return err;
181
181
}
182
182
183
+ Error GUI::DisplayError (const Error &err) {
184
+ if (!err->IsError () || err->UserMessage ().empty ()) {
185
+ return NoError {};
186
+ }
187
+
188
+ logger.error (err);
189
+
190
+ if (err->Class () == " NetworkingError" ) {
191
+ logger.debug (" You are offline (" , err, " )" );
192
+ /* TODO
193
+ auto nErr = err.promote<NetworkingError>();
194
+ if (nErr->Type() == NetworkingError::BACKEND_OFFLINE) {
195
+ DisplayOnlineState(kOnlineStateBackendDown);
196
+ }
197
+ else {
198
+ DisplayOnlineState(kOnlineStateNoNetwork);
199
+ }
200
+ */
201
+ return err;
202
+ }
203
+
204
+ // making error actionable is not necessary with Error
205
+ // determining if error is user error is not necessary as well
206
+
207
+ char_t *err_s = copy_string (err->UserMessage ());
208
+ on_display_error_ (err_s, true );
209
+ free (err_s);
210
+
211
+ lastErr = err->UserMessage ();
212
+
213
+ return err;
214
+ }
215
+
183
216
error GUI::DisplayWSError () {
184
217
on_display_overlay_ (0 );
185
218
return noError;
Original file line number Diff line number Diff line change @@ -327,6 +327,7 @@ class TOGGL_INTERNAL_EXPORT GUI : public SyncStateMonitor {
327
327
void DisplayApp ();
328
328
329
329
error DisplayError (const error &err);
330
+ Error DisplayError (const Error &err);
330
331
331
332
// Overlay screen triggers
332
333
error DisplayWSError ();
You can’t perform that action at this time.
0 commit comments