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



------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
wxCode-users mailing list
wxCode-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxcode-users

Reply via email to