× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi all..



Does anyone have ideas how Java can report an error for a Java toolbox
class when it doesn't throw an exception? Is there any way to
programmatically dig out the cause when a method returns a value
indicating the underlying i5 operation failed, but doesn't throw an
error?



This code run on a windows server, it sets up the File objects to copy a
jpg image from the Windows server to an i5.



// ensure that parent dir of dest file exists!

IFSFile parent = new IFSFile(sys, parentPath);

if (!parent.exists()) {

parent.mkdirs();

}



try {

in = new FileInputStream(sourceFile);

} catch( IOException e ) {

throw new Exception ( "Problem with input file,
\""+sourceFile.getAbsolutePath()+"\" " + e.getMessage() );

}

try {

out = new IFSFileOutputStream(destFile);

} catch( IOException e ) {

throw new Exception ( "Problem with output file,
\""+destFile.getAbsolutePath()+"\" " + e.getMessage() );

}



Today the IFSFileOutputStream(destFile) started to throw errors.



The problem is caused by IFSFile.mkdirs() failing. It fails silently,
returning false.



I could change the code to:



if (!parent.exists()) {

if( !parent.mkdirs() ) {

throw new Exception("Unable to create parent folder,
\""+parent.getAbsolutePath()+"\" ) ;

}

}



That would notify the caller of the method that a failure took place,
but not the cause of the failure. parentPath is validated before the
execution gets this far so IFSFile.mkdirs() shouldn't fail in the first
place.



The failure is being caused by CPE3474, our IT department is working on
that.



I'd like to do something like this to report why IFSFile.mkdirs()
failed:



if (!parent.exists()) {

if( !parent.mkdirs() ) {

// do something to dig out cause of error

throw new Exception("Unable to create parent folder,
\""+parent.getAbsolutePath()+"\ caused by " + cause_of_error);

}

}



Any ideas what to replace the // do something... comment with?



Thanks

Bill Blalock

















_____________

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
_____________

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.