How to determine the correct constraint violation in SQLite UpdateException?

I have the following problem with my local SQLite database. I am trying to update data stored during synchronization with the SQL Server online database. Despite the lack of synchronization problems, I often encounter errors when trying to update local values. For instance. there may be a violation with the existing Master key restrictions for each table. On the other hand, there may also be a violation of a unique key on a particular table.

My question is how to find out what type of error has occurred.

I catch a database update or insert as

catch(UpdateException ue)
{
    HandleUpdateException(ue);
}

The descriptor method is as follows:

private void HandleUpdateException(UpdateException e)
{
    // get inner exception as SQLiteException
    var innerException = e.InnerException as SQLiteException;

    if(innerException != null)
    {
        switch(innerException.ErrorCode)
        {
            case SQLiteError.Constraint:
                // handle constraint-error here
                break;
            default:
                // log error
                break;
        }
    }
}

? , PK- UK.

if(e.Message.Contains("unique")) // ...

if(e.Message.Contains("foreign")) // ...

"" .

.

+5

All Articles