On 2016/01/14 3:02 PM, sanhua.zh wrote: > 1. Not all other codes except SQLITE_OK, SQLITE_ROW, SQLITE_DONE should be > treated as fatal errors. > As an example, SQLITE_BUSY indicates that this op is temporarily failed, > but it can be done later. (Note that sometimes you should not retry forever.) > Another example, while SQLITE_FULL,manually cleaning your pragram cache to > make some free space might be a better way than crash your app.
The error codes (fully error-specific codes, that is) are not suggestive, they are absolute. If you do not quit immediately, you should at least stop trying to access the database immediately. If there was something that could be done about the error, SQLite would have done it, the error code means SQLite is sure there is nothing that can be done and so warns you that you should stop and report. (SQLite_BUSY isn't an error code so much as a status code - if the situation persists beyond a reasonable time (longer than any of your transactions might take on a slow device), then it should be regarded as an error.) > 2. Quit while get error is also not a great enough idea. Because not all > pragram is a command line tool. It can be a user-oriented application instead > of a developer-oriented tool. Users don?t wish to meet a crash. This is very much wrong - when Out-of-memory and out-of-diskspace type errors are reported, you should immediately halt what you are doing and release all possible resources soonest. Consider that the user might have another thing on their system trying to write/read/work, and you are insisting to occupy some part of it - please don't. Once a user's system gets to that stage, they need immediate help (if they are not technical). That situation is long-past the point where you could care to provide user-niceness. Show a warning/error and die. If you want to be user-happy-fancy, then check diskspace before you start any transaction, and keep a record of disk usage during transactions - when the free space starts shrinking to near the maximum usage on record, start cleaning your own caches, start showing warnings / advise disk-health routines or device-service time.