From: Ulrich T. <ulr...@gm...> - 2013-12-26 21:30:13
|
Paul, Am 26.12.2013 14:57, schrieb pao_drop: > I am writing a pdf file using the SaveAsFile() method of wxPDFDocument. > This works quite well, but how can I handle a file writing error (for > instance, trying to write into a protected directory...)? > The return type of SaveAsFile() is void, and it does not appear to throw > any exception? As far as I can remember wxWidgets itself shows an error message through wxLogError if the write operation fails. Maybe not the ideal solution. > So how can I manage this case? You should verify that the file of which you path the name to method SaveAsFile is indeed writable, before calling SaveAsFile. In my own applications I sometimes let method SaveAsFile write to a temporary file and rename the file thereafter. If renaming fails I issue an appropriate error message and let the user choose what to do - either retry (if the file was locked by another application) or choose a new file name. Regards, Ulrich |