insertOrThrow to provide information about errors #355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently if an insert fails, the developer is left guessing as to why. If AA used insertOrThrow instead, there would be information about what happened. If an app is relying on the current relatively silent failure of inserts, it may crash after this update. The unfortunate thing is the exception thrown will be a runtime exception, so the compiler will not inform the dev that he needs to change anything. However, I would argue that it's worth the risk to give developers the information they need to produce correct apps. Currently I have a "debug save" version of the Model.save() method that doesn't actually do everything a save operation needs to do, but at least tells me what's going wrong with an insert. So if I find a problem with an insert I have to switch to the debug method, and then switch back after fixing it.