From 246401ab6bf788c01398fe9555bea58851c63a0a Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 10 Apr 2013 19:35:39 +0000 Subject: Provide error message for cmd line args git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@401 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../workflow/states/PrepareConfigurationState.java | 43 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'pdf-over-gui/src/main/java') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java index 93e5844c..2c4ef3bf 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -277,16 +277,51 @@ public class PrepareConfigurationState extends State { } // Read cli arguments for config file first - this.initializeFromArguments(this.stateMachine.getCmdArgs(), - this.configFileHandler); + try { + this.initializeFromArguments(this.stateMachine.getCmdArgs(), + this.configFileHandler); + } catch (InitializationException e) { + log.error("Error in cmd line arguments: ", e); //$NON-NLS-1$ + ErrorDialog error = new ErrorDialog(this.stateMachine + .getGUIProvider().getMainShell(), + Messages.getString("error.CmdLineArgs"), //$NON-NLS-1$ + BUTTONS.OK); + // error.setException(e); + // this.setNextState(error); + error.open(); + this.stateMachine.exit(); + } // initialize from config file this.initializeFromConfigurationFile(this.stateMachine .getConfigProvider().getConfigurationFile()); // Read cli arguments - this.initializeFromArguments(this.stateMachine.getCmdArgs(), - this.handler); + try { + this.initializeFromArguments(this.stateMachine.getCmdArgs(), + this.handler); + } catch (InitializationException e) { + log.error("Error in cmd line arguments: ", e); //$NON-NLS-1$ + ErrorDialog error; + + if (e.getCause() instanceof FileNotFoundException) { + error = new ErrorDialog(this.stateMachine + .getGUIProvider().getMainShell(), + String.format( + Messages.getString("error.FileNotExist"), //$NON-NLS-1$ + e.getCause().getMessage()), + BUTTONS.OK); + } else { + error = new ErrorDialog(this.stateMachine + .getGUIProvider().getMainShell(), + Messages.getString("error.CmdLineArgs"), //$NON-NLS-1$ + BUTTONS.OK); + } + // error.setException(e); + // this.setNextState(error); + error.open(); + this.stateMachine.exit(); + } // Set usedSignerLib ... this.stateMachine.getPDFSigner().setUsedPDFSignerLibrary( -- cgit v1.2.3