diff options
author | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-14 13:27:06 +0200 |
---|---|---|
committer | Jakob Heher <jakob.heher@iaik.tugraz.at> | 2022-07-14 13:27:06 +0200 |
commit | bf04fba3b1ff92b4288c37c474c8e4b9d4e2e342 (patch) | |
tree | 772122c26ea4ce387bad3ff27dc8d82910cb8827 /pdf-over-gui/src/main | |
parent | d8455be73b62176f85a4008efd733497b7b13711 (diff) | |
download | pdf-over-bf04fba3b1ff92b4288c37c474c8e4b9d4e2e342.tar.gz pdf-over-bf04fba3b1ff92b4288c37c474c8e4b9d4e2e342.tar.bz2 pdf-over-bf04fba3b1ff92b4288c37c474c8e4b9d4e2e342.zip |
better error message if internet connection is unavailable
cf. #47
Diffstat (limited to 'pdf-over-gui/src/main')
3 files changed, 16 insertions, 17 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index 09f67602..594e46c8 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -16,6 +16,7 @@ package at.asit.pdfover.gui.workflow.states;
import java.io.InputStream;
+import java.net.UnknownHostException;
import java.util.Timer;
import java.util.TimerTask;
@@ -164,11 +165,18 @@ public class MobileBKUState extends State { * the exception
*/
public void displayError(Exception e) {
- String message = Messages.getString("error.Unexpected");
- log.error(message, e);
- String errormsg = e.getLocalizedMessage();
- if (errormsg != null && !errormsg.isEmpty())
- message += ": " + errormsg;
+ String message = null;
+ if (e instanceof UnknownHostException)
+ {
+ log.error("Failed to resolve hostname", e);
+ message = String.format(Messages.getString("error.CouldNotResolveHostname"), e.getMessage());
+ } else {
+ message = Messages.getString("error.Unexpected");
+ log.error(message, e);
+ String errormsg = e.getLocalizedMessage();
+ if (errormsg != null && !errormsg.isEmpty())
+ message += ": " + errormsg;
+ }
displayError(message);
}
@@ -548,18 +556,7 @@ public class MobileBKUState extends State { this.signingState.setUseBase64Request(this.handler.useBase64Request());
if (this.threadException != null) {
- String message = Messages.getString("error.Unexpected");
- log.error(message, this.threadException);
- String errormsg = this.threadException.getLocalizedMessage();
- if (errormsg != null && !errormsg.isEmpty())
- message += ": " + errormsg;
- ErrorDialog error = new ErrorDialog(
- getStateMachine().getMainShell(),
- message, BUTTONS.OK);
- // error.setException(this.threadException);
- // this.setNextState(error);
- error.open();
- getStateMachine().exit();
+ displayError(this.threadException);
return;
}
diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties index 2423d621..e8724ac7 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties @@ -130,6 +130,7 @@ dataSourceSelection.browse=&Browse for PDF on your computer dataSourceSelection.usePlaceholderText=A marker has been found where the creator of the document wants you to put your signature. Do you want to use it? dataSourceSelection.usePlaceholderTitle=Info error.ATrustConnection=Connection to A-Trust could not be established +error.CouldNotResolveHostname=Could not resolve hostname '%s'.\nAre you connected to the internet? error.CmdLineArgs=Error parsing the command-line arguments\: error.Details=Details error.EnteredReferenceValue=You entered the reference value\! diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties index 3ef421c0..355720ab 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties @@ -159,6 +159,7 @@ error.Title=Fehler error.TitleFatal=Fataler Fehler error.Unexpected=Unerwarteter Fehler error.ATrustConnection=Verbindung zu A-Trust konnte nicht aufgebaut werden +error.CouldNotResolveHostname=Server '%s' wurde nicht gefunden.\nÜberprüfen Sie Ihre Internetverbindung. exception.InvalidEmblemFile=%s ist eine ungültige Bildmarken-Datei\! exception.InvalidPort=%s ist ungültig\: muss eine Nummer zwischen %d und %d sein. exception.PasswordTooLong=Eingegebenes Passwort ist zu lange\! |