Fix[msa]: handle PresentedExceptions without a set cause

This commit is contained in:
artdeell 2023-12-10 14:51:27 +03:00
parent 1e8e1757ab
commit af4ae5e919
2 changed files with 8 additions and 2 deletions

View File

@ -99,9 +99,15 @@ public class mcAccountSpinner extends AppCompatSpinner implements AdapterView.On
private final ErrorListener mErrorListener = errorMessage -> {
mLoginBarPaint.setColor(Color.RED);
Context context = getContext();
if(errorMessage instanceof PresentedException) {
PresentedException exception = (PresentedException) errorMessage;
Tools.showError(getContext(), exception.toString(getContext()), exception.getCause());
Throwable cause = exception.getCause();
if(cause == null) {
Tools.dialog(context, context.getString(R.string.global_error), exception.toString(context));
}else {
Tools.showError(context, exception.toString(context), exception.getCause());
}
}else {
Tools.showError(getContext(), errorMessage);
}

View File

@ -104,7 +104,7 @@ public class MicrosoftBackgroundLogin {
}
}catch (Exception e){
Log.e("MicroAuth", e.toString());
Log.e("MicroAuth", "Exception thrown during authentication", e);
if(errorListener != null)
Tools.runOnUiThread(() -> errorListener.onLoginError(e));
}