Add more specific error message related to ssl connection problems.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-01-21 21:01:21 +01:00
parent 9389af5a79
commit efe1efdda6
7 changed files with 40 additions and 29 deletions

View File

@ -30,6 +30,10 @@ import org.moire.ultrasonic.subsonic.RestErrorMapper;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertificateException;
import javax.net.ssl.SSLException;
/**
* @author Sindre Mehus
@ -69,39 +73,34 @@ public abstract class BackgroundTask<T> implements ProgressListener
new ErrorDialog(activity, getErrorMessage(error), true);
}
protected String getErrorMessage(Throwable error)
{
if (error instanceof IOException && !Util.isNetworkConnected(activity))
{
return activity.getResources().getString(R.string.background_task_no_network);
}
if (error instanceof FileNotFoundException)
{
return activity.getResources().getString(R.string.background_task_not_found);
}
if (error instanceof JsonParseException) {
protected String getErrorMessage(Throwable error) {
if (error instanceof IOException && !Util.isNetworkConnected(activity)) {
return activity.getResources().getString(R.string.background_task_no_network);
} else if (error instanceof FileNotFoundException) {
return activity.getResources().getString(R.string.background_task_not_found);
} else if (error instanceof JsonParseException) {
return activity.getResources().getString(R.string.background_task_parse_error);
}
if (error instanceof IOException)
{
return activity.getResources().getString(R.string.background_task_network_error);
}
if (error instanceof SubsonicRESTException) {
} else if (error instanceof SSLException) {
if (error.getCause() instanceof CertificateException &&
error.getCause().getCause() instanceof CertPathValidatorException) {
return activity.getResources()
.getString(R.string.background_task_ssl_cert_error,
error.getCause().getCause().getMessage());
} else {
return activity.getResources().getString(R.string.background_task_ssl_error);
}
} else if (error instanceof IOException) {
return activity.getResources().getString(R.string.background_task_network_error);
} else if (error instanceof SubsonicRESTException) {
return RestErrorMapper.getLocalizedErrorMessage((SubsonicRESTException) error, activity);
}
String message = error.getMessage();
if (message != null)
{
return message;
}
return error.getClass().getSimpleName();
}
String message = error.getMessage();
if (message != null) {
return message;
}
return error.getClass().getSimpleName();
}
@Override
public abstract void updateProgress(final String message);

View File

@ -6,6 +6,8 @@
<string name="background_task.no_network">Este programa requiere acceso a la red. Por favor enciende la Wi-Fi o la red móvil.</string>
<string name="background_task.not_found">Recurso no encontrado. Por favor comprueba la dirección del servidor.</string>
<string name="background_task.parse_error">No se entiende la respuesta. Por favor comprueba la dirección del servidor.</string>
<string name="background_task.ssl_cert_error">Error del certificado HTTPS: %1$s.</string>
<string name="background_task.ssl_error">Excepción de conexión SSL. Compruebe el certificado del servidor.</string>
<string name="background_task.wait">Por favor espera&#8230;</string>
<string name="button_bar.bookmarks">Marcadores</string>
<string name="button_bar.browse">Biblioteca</string>

View File

@ -6,6 +6,8 @@
<string name="background_task.no_network">Cette application requiert un accès au réseau. Veuillez activer le Wi-Fi ou le réseau mobile.</string>
<string name="background_task.not_found">Ressources introuvables. Veuillez vérifier l\'adresse du serveur.</string>
<string name="background_task.parse_error">Réponse incorrecte. Veuillez vérifier l\'adresse du serveur.</string>
<string name="background_task.ssl_cert_error">Erreur de certificat HTTPS: %1$s.</string>
<string name="background_task.ssl_error">Exception de connexion SSL. Veuillez vérifier le certificat du serveur.</string>
<string name="background_task.wait">Veuillez patienter&#8230;</string>
<string name="button_bar.bookmarks">Signets</string>
<string name="button_bar.browse">Bibliothèque musicale</string>

View File

@ -6,6 +6,8 @@
<string name="background_task.no_network">Az alkalmazás hálózati hozzáférést igényel. Kérjük, kapcsolja be a Wi-Fi-t vagy a mobilhálózatot!</string>
<string name="background_task.not_found">Az erőforrás nem található! Kérjük, ellenőrizze a kiszolgáló címét!</string>
<string name="background_task.parse_error">Értelmezhetetlen válasz! Kérjük, ellenőrizze a kiszolgáló címét!</string>
<string name="background_task.ssl_cert_error">HTTPS tanúsítványhiba: %1$s.</string>
<string name="background_task.ssl_error">SSL kapcsolat kivétel. Kérjük, ellenőrizze a szerver tanúsítványát.</string>
<string name="background_task.wait">Kérem várjon!&#8230;</string>
<string name="button_bar.bookmarks">Könyvjelzők</string>
<string name="button_bar.browse">Médiakönyvtár</string>

View File

@ -6,6 +6,8 @@
<string name="background_task.no_network">Este aplicativo requer acesso à rede. Ligue o Wi-Fi ou a rede de dados.</string>
<string name="background_task.not_found">Recurso não encontrado. Verifique o endereço do servidor.</string>
<string name="background_task.parse_error">Não entendi a resposta. Verifique o endereço do servidor.</string>
<string name="background_task.ssl_cert_error">Erro de certificado HTTPS: %1$s.</string>
<string name="background_task.ssl_error">Exceção de conexão SSL. Verifique o certificado do servidor.</string>
<string name="background_task.wait">Por favor aguarde&#8230;</string>
<string name="button_bar.bookmarks">Favoritos</string>
<string name="button_bar.browse">Biblioteca de Mídia</string>

View File

@ -6,6 +6,8 @@
<string name="background_task.no_network">Este aplicativo requer acesso à rede. Ligue o Wi-Fi ou a rede de dados.</string>
<string name="background_task.not_found">Recurso não encontrado. Verifique o endereço do servidor.</string>
<string name="background_task.parse_error">Não entendi a resposta. Verifique o endereço do servidor.</string>
<string name="background_task.ssl_cert_error">Erro de certificado HTTPS: %1$s.</string>
<string name="background_task.ssl_error">Exceção de conexão SSL. Verifique o certificado do servidor.</string>
<string name="background_task.wait">Por favor aguarde&#8230;</string>
<string name="button_bar.bookmarks">Favoritos</string>
<string name="button_bar.browse">Biblioteca de Mídia</string>

View File

@ -6,6 +6,8 @@
<string name="background_task.no_network">This program requires network access. Please turn on Wi-Fi or mobile network.</string>
<string name="background_task.not_found">Resource not found. Please check the server address.</string>
<string name="background_task.parse_error">Didn\'t understand the reply. Please check the server address.</string>
<string name="background_task.ssl_cert_error">HTTPS certificate error: %1$s.</string>
<string name="background_task.ssl_error">SSL connection exception. Please check server certificate.</string>
<string name="background_task.wait">Please wait&#8230;</string>
<string name="button_bar.bookmarks">Bookmarks</string>
<string name="button_bar.browse">Media Library</string>