Click here to Skip to main content
15,887,280 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to customize my error messages like the 'Unique Constrain Failed' and the 'Table does not exist' exception. How do I do this?

What I have tried:

catch (SQLiteException ex)
            {
                MessageBox.Show("Error "+ex);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex);
            }


Gives too much technical errors which will confuse users. I do not expect my users to see any errors but if they do, I want them to see proper ones. How do I check which type of error is caught by the SQLiteException?
Posted
Updated 20-Jan-18 23:33pm

1 solution

SqLite uses error codes, which the SqLiteConnection, SqLiteCommand, and suchlike classes convert into Exceptions. Having said that, the SqLiteException class returns teh error code to your app: SqliteException.SqliteErrorCode Property[^] - so you can use that to determine what the problem is and report that to your users.
There is a table here[^] which "names" the error codes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900