This repository was archived by the owner on Feb 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Expand file tree Collapse file tree 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) {
10611061 return UI ()->DisplayError (err);
10621062}
10631063
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+
10641099int Context::nextSyncIntervalSeconds () const {
10651100 int n = static_cast <int >(Random::next (kSyncIntervalRangeSeconds )) + kSyncIntervalRangeSeconds ;
10661101 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 {
671671 void updateUI (const UIElements &elements);
672672
673673 error displayError (const error &err);
674+ error reportError (const Error &err);
674675
675676 void scheduleSync ();
676677
Original file line number Diff line number Diff line change @@ -180,6 +180,39 @@ error GUI::DisplayError(const error &err) {
180180 return err;
181181}
182182
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+
183216error GUI::DisplayWSError () {
184217 on_display_overlay_ (0 );
185218 return noError;
Original file line number Diff line number Diff line change @@ -327,6 +327,7 @@ class TOGGL_INTERNAL_EXPORT GUI : public SyncStateMonitor {
327327 void DisplayApp ();
328328
329329 error DisplayError (const error &err);
330+ Error DisplayError (const Error &err);
330331
331332 // Overlay screen triggers
332333 error DisplayWSError ();
You can’t perform that action at this time.
0 commit comments