Author: jacopoc
Date: Fri Mar 23 10:13:32 2007
New Revision: 521812
URL:
http://svn.apache.org/viewvc?view=rev&rev=521812Log:
Better error handling for printer's invalid URI.
Thanks to Jacques Le Roux for the bug report.
Modified:
ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java
Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java?view=diff&rev=521812&r1=521811&r2=521812==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/print/PrintServices.java Fri Mar 23 10:13:32 2007
@@ -148,9 +148,13 @@
Doc myDoc = new SimpleDoc(bais, psInFormat, null);
PrintServiceAttributeSet psaset = new HashPrintServiceAttributeSet();
if (UtilValidate.isNotEmpty(printerName)) {
- URI printerUri = new URI(printerName);
- PrinterURI printerUriObj = new PrinterURI(printerUri);
- psaset.add(printerUriObj);
+ try {
+ URI printerUri = new URI(printerName);
+ PrinterURI printerUriObj = new PrinterURI(printerUri);
+ psaset.add(printerUriObj);
+ } catch (URISyntaxException ue) {
+ Debug.logWarning(ue, "Invalid URI for printer [" + printerName + "]", module);
+ }
}
//PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, psaset); // TODO: selecting the printer by URI seems to not work
PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, null);
@@ -183,10 +187,6 @@
return ServiceUtil.returnError(errMsg);
}
- } catch (URISyntaxException ue) {
- String errMsg = "Error retrieving printer [" + printerName + "]: " + ue.toString();
- Debug.logError(ue, errMsg, module);
- return ServiceUtil.returnError(errMsg);
} catch (PrintException pe) {
String errMsg = "Error printing [" + contentType + "]: " + pe.toString();
Debug.logError(pe, errMsg, module);