Avoid to lost the composed message when an error occurs

This commit is contained in:
tom79 2020-02-04 18:40:28 +01:00
parent 7af7c51520
commit fd0cf63439
2 changed files with 3 additions and 2 deletions

View File

@ -2683,7 +2683,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
showAToast(apiResponse.getError().getError()); showAToast(apiResponse.getError().getError());
return; return;
} }
} }
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS + userId + instance, false); boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS + userId + instance, false);

View File

@ -52,6 +52,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -4719,6 +4720,7 @@ public class API {
e.printStackTrace(); e.printStackTrace();
} catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) { } catch (NoSuchAlgorithmException | IOException | KeyManagementException | JSONException e) {
e.printStackTrace(); e.printStackTrace();
setDefaultError(e);
} }
apiResponse.setStatuses(statuses); apiResponse.setStatuses(statuses);
return apiResponse; return apiResponse;
@ -6469,7 +6471,7 @@ public class API {
APIError.setStatusCode(statusCode); APIError.setStatusCode(statusCode);
String message = statusCode + " - " + error.getMessage(); String message = statusCode + " - " + error.getMessage();
try { try {
JSONObject jsonObject = new JSONObject(error.getMessage()); JSONObject jsonObject = new JSONObject(Objects.requireNonNull(error.getMessage()));
String errorM = jsonObject.get("error").toString(); String errorM = jsonObject.get("error").toString();
message = "Error " + statusCode + " : " + errorM; message = "Error " + statusCode + " : " + errorM;
} catch (JSONException e) { } catch (JSONException e) {