Author: joern Date: Thu Jul 14 09:39:48 2011 New Revision: 1146611 URL: http://svn.apache.org/viewvc?rev=1146611&view=rev Log: UIMA-1787 Error dialog now always shows an error message, and is no longer empty.
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/DocumentImportStructureProvider.java uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/ImportDocumentWizard.java Modified: uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/DocumentImportStructureProvider.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/DocumentImportStructureProvider.java?rev=1146611&r1=1146610&r2=1146611&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/DocumentImportStructureProvider.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/DocumentImportStructureProvider.java Thu Jul 14 09:39:48 2011 @@ -95,8 +95,10 @@ final class DocumentImportStructureProvi } } - private InputStream getDocument(String text, DocumentFormat format) { + private InputStream getDocument(String fileName, String text, DocumentFormat format) { + String failedToImportLine = "Failed to import: " + fileName + "\n\n"; + CAS cas = createEmtpyCAS(); cas.setDocumentText(text); @@ -107,10 +109,10 @@ final class DocumentImportStructureProvi XCASSerializer.serialize(cas, out); } catch (SAXException e) { // should not happen - throw new TaeError("Unexpected exception!", e); + throw new TaeError(failedToImportLine + e.getMessage(), e); } catch (IOException e) { // will not happen, writing to memory - throw new TaeError("Unexpected exception!", e); + throw new TaeError(failedToImportLine + e.getMessage(), e); } } else if (DocumentFormat.XMI.equals(format)) { @@ -118,10 +120,10 @@ final class DocumentImportStructureProvi XmiCasSerializer.serialize(cas, out); } catch (SAXException e) { // should not happen - throw new TaeError("Unexpected exception!", e); + throw new TaeError(failedToImportLine + e.getMessage(), e); } } else { - throw new TaeError("Unkown document type!", null); + throw new TaeError(failedToImportLine + "Unkown document type!", null); } return new ByteArrayInputStream(out.toByteArray()); @@ -139,7 +141,7 @@ final class DocumentImportStructureProvi in = new FileInputStream((File) element); String text = convert(in); - return getDocument(text, casFormat); + return getDocument(fileToImport.getAbsolutePath(), text, casFormat); } catch (FileNotFoundException e) { return null; } catch (IOException e) { @@ -169,7 +171,7 @@ final class DocumentImportStructureProvi textStringBuffer.append(new String(readBuffer, 0, length, importEncoding)); } - return getDocument(textStringBuffer.toString(), casFormat); + return getDocument(fileToImport.getAbsolutePath(), textStringBuffer.toString(), casFormat); } catch (FileNotFoundException e) { return null; } catch (IOException e) { Modified: uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/ImportDocumentWizard.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/ImportDocumentWizard.java?rev=1146611&r1=1146610&r2=1146611&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/ImportDocumentWizard.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/wizards/ImportDocumentWizard.java Thu Jul 14 09:39:48 2011 @@ -71,8 +71,19 @@ public final class ImportDocumentWizard getContainer().run(true, true, operation); } catch (InvocationTargetException e) { CasEditorPlugin.log(e); - - MessageDialog.openError(getContainer().getShell(), "Error during import", e.getMessage()); + + String message = "Unkown error during import, see the log file for details"; + + Throwable cause = e.getCause(); + if (cause != null) { + + String causeMessage = cause.getMessage(); + + if (causeMessage != null) + message = causeMessage; + } + + MessageDialog.openError(getContainer().getShell(), "Import failed", message); return false; } catch (InterruptedException e) {