Please add the attached category files to your Swift project, and include the header in your bridging header. The category will add a new class method to PTPDFNet, catchException.
You can then use the following pattern to handle exceptions thrown by PDFNet:
do { try PTPDFNet.catchException { // code that may throw an exception doc = PTPDFDoc(filepath: docPath!) } } catch { print("Caught exception") }
This method will be included in the next version of PDFNet (without the need to add it via a category).