Hi there,
We are currently using Aspose.Words for java - version 13.12.0 in our production. We are planning to change it to latest version (14.6.0). We are seeing that lots of APIs in classes are now throwing the checked exception “java.lang.Exception” and have to be dealt with explicitly.
The problem is we don’t want to throw them up and these are not explicit enough. If we try to catch them (they are lot now), how can we know that whether the exception is thrown by Aspose or not.
Could you please look into this?
Thanks.
Hi Praneeth,
Thanks for your inquiry. Checked exceptions are valuable for small applications; but they are almost useless for big applications/libraries with deep hierarchy like Aspose.Words. Please note that you do not need explicit handling of all these exceptions, you can just propagate them further. You need in-line try-catch block only if you know the low level problem and can fix it – reread data, use another connection/coder, etc.
Most of the getters call internally some methods from external libraries (I/O or graphics) that contain checked exceptions in their signatures. We can't foresee all I/O, graphics, XML, etc. problems to isolate low-level exceptions. So we added Exception to our signatures too. Anyway Aspose.Words catches most basic cases internally. For instance, if an image can't be loaded or properly read, Aspose.Words just inserts red cross instead of invalid/unavailable image.
I hope, this helps.
Best regards,
That’s fine and we understand the value of exception being thrown but if we can distinguish it or have a subclass of Exception, something like AsposeInternalException etc, that would be very helpful and appreciable. Currently it is the whole java.lang.Exception being thrown. Thanks for looking into this.
Hi Praneeth,
Thanks for your inquiry. We have logged your requirement in our issue tracking system as WORDSJAVA-924. We will further look into the details of this requirement and keep you updated on the status. We apologize for any inconvenience.
Best regards,
Hi Praneeth,
Regarding WORDSJAVA-924, our product team has completed the work on your issue and has come to a conclusion that they won’t be able to implement the fix to your issue. Your issue (WORDSJAVA-924) is now closed with ‘Won’t Fix’ resolution. This is a design pattern in Aspose.Words. Most of the methods can throw exceptions and therefore all have the throws clause. Unfortunately, we cannot change that. It is an acceptable pattern in Java programming.
Best regards,