Catching SQLITEFULL exception

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
Post Reply
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Catching SQLITEFULL exception

Post by deepti »

Hi,

Currently our application has several exception catch blocks like this:

Code: Select all

catch (wxSQLite3Exception& e)
 {
 //log the exception message
 }
 
I read in the documentation that SQLITEFULL exception can occur even when writing to temporary files like journal files.
Now, i need a way to shutdown the application in case of SQLITEFULL exception.
But, checking if the exception type is SQLITEFULL in each of these catch blocks does not seem like a great approach.
Is there a simpler way to do this?
Please help!
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Catching SQLITEFULL exception

Post by utelle »

deepti wrote: Wed Jul 17, 2019 6:05 pm Currently our application has several exception catch blocks like this:

Code: Select all

catch (wxSQLite3Exception& e)
{
  // log the exception message
} 
I read in the documentation that SQLITE_FULL exception can occur even when writing to temporary files like journal files.
Yes, that is correct.
deepti wrote: Wed Jul 17, 2019 6:05 pm Now, i need a way to shutdown the application in case of SQLITE_FULL exception.
But, checking if the exception type is SQLITE_FULL in each of these catch blocks does not seem like a great approach.
Is there a simpler way to do this?
No. If you catch a wxSQLite3Exception, then you have to handle the exception.

To avoid code duplication, you could write a separate function, which checks for this special condition, and - if the error code was SQLITE_FULL - this function could then throw an application specific condition, which you then catch in your main application, or this function could shutdown the application directly. Then you add a call to this function in each catch block.
deepti
Earned some good credits
Earned some good credits
Posts: 115
Joined: Tue Jul 17, 2018 5:38 pm

Re: Catching SQLITEFULL exception

Post by deepti »

Thank you Utelle for your detailed explanation.
Post Reply