John Varady
10/17/2022, 1:03 PMCould not initialize class com.sun.star.lib.loader.WinRegKey
I'd like to be able to attempt to convert and catch the error but that seems impossible-
<cftry>
<cfdocument format='pdf' srcfile='C:\ColdFusionWebroot\upload-testing\6personal_essay.docx' name='mydoc' />
<cfcatch type='any'>
<cfdump var='#cfcatch#'>
</cfcatch>
</cftry>
Adam Cameron
<cfdocument>
, it needs to be able to load the libs it needs to do so.
Not sure this is the right place in the application's code to deal with this sort of thing.John Varady
10/17/2022, 2:36 PMAdam Cameron
If there a graceful way to know if openoffice is installed?Can't answer that. I doubt there is, but you could look for some top level class like org.openoffice.ThisIsTheMainThing, and write a wrapper around trying to instantiate one of those or something?
isOpenOfficeInstalled() {
try {
createObject("java", "whatevs")
return true
} catch (any e) {
return false
}
}
(Obvs integration test that with it both installed and not installed ;-))
I would have expected a trappable error to occur when calling cfdocument.I can understand how a plugin might be needed at compile time to even be able to compile the code. it's sloppy (for the reasons you allude to), but hey ho... this is ColdFusion, and "something being implemented sloppily" should not come as too much of a surprise. Also: I am just guessing it's a compile-time error. You didn't share the relevant bit of said error message.
Where in the code would you deal with this?If OpenOffice ain't installed, shouldn't even be calling code that tries to use it. How does the logic flow get started to end up wanting to use
<cfdocument>
when the module needed to do so isn't installed? That's where I'd head things off. Let's say you have an "export to PDF" link in your UI, and that's where this all starts. Feature toggle the display of that based on whether you can actually do it or not.
My rule of thumb is that "the line of code where the error is occurring" is seldom where the source of the issue is. If you start with that premise, and aim to solve the problem not treat the symptom of the problem, you'll likely end up with better designed code.
(that said I have to guess all this cos there's only the one line of code to work with, and no real context. So... I'm guessing...)John Varady
10/18/2022, 11:10 AM