@@ -258,26 +258,33 @@ QJsonObject Flow2Auth::handleResponse(QNetworkReply *reply)
258258 if (httpStatus == 503 ) {
259259 errorReason = tr (" The server is temporarily unavailable because it is in maintenance mode. "
260260 " Please try again once maintenance has finished." );
261- } else if (const QString errorFromJson = json[" error" ].toString ();
261+ } else if (const auto errorFromJson = json[" error" ].toString ();
262262 !errorFromJson.isEmpty ()) {
263- errorReason = tr (" Error returned from the server: <em>%1</em>" )
264- .arg (errorFromJson.toHtmlEscaped ());
263+ errorReason = tr (" An unexpected error occurred when trying to access the server. "
264+ " Please try to access it again later or contact your server administrator if the issue continues." );
265+ qCWarning (lcFlow2auth) << " Error returned from JSON:" << errorFromJson;
265266 } else if (reply->error () != QNetworkReply::NoError) {
266267 auto errorStringFromReply = reply->errorString ();
267268 if (const auto hstsError = AbstractNetworkJob::hstsErrorStringFromReply (reply)) {
268269 errorStringFromReply = *hstsError;
269270 }
270- errorReason = tr (" There was an error accessing the \" token\" endpoint: <br><em>%1</em>" )
271- .arg (errorStringFromReply.toHtmlEscaped ());
272- } else if (jsonParseError.error != QJsonParseError::NoError) {
273- errorReason = tr (" Could not parse the JSON returned from the server: <br><em>%1</em>" )
274- .arg (jsonParseError.errorString ());
271+ errorReason = tr (" An unexpected error occurred when trying to access the server. "
272+ " Please try to access it again later or contact your server administrator if the issue continues." );
273+ qCWarning (lcFlow2auth) << " Error string returned from the server:" << errorStringFromReply;
274+ } else if (jsonParseError.error != QJsonParseError::NoError || json.isEmpty ()) {
275+ // Could not parse the JSON returned from the server
276+ errorReason = tr (" We couldn't parse the server response. "
277+ " Please try connecting again later or contact your server administrator if the issue continues." );
275278 } else if (json.isEmpty ()) {
276- errorReason = tr (" The reply from the server did not contain all expected fields: <br><em>%1</em>" )
277- .arg (jsonParseError.errorString ());
279+ // The reply from the server did not contain all expected fields
280+ errorReason = tr (" The server did not reply with the expected data. "
281+ " Please try connecting again later or contact your server administrator if the issue continues." );
278282 }
279283
280- qCWarning (lcFlow2auth) << " Error when requesting:" << reply->url () << " - json returned:" << json << " - error:" << errorReason;
284+ qCWarning (lcFlow2auth) << " Error when requesting:" << reply->url ()
285+ << " - json returned:" << json
286+ << " - http status code:" << httpStatus
287+ << " - error:" << jsonParseError.errorString ();
281288
282289 // We get a 404 until authentication is done, so don't show this error in the GUI.
283290 if (reply->error () != QNetworkReply::ContentNotFoundError) {
0 commit comments