Subject: | 'safe' operations returning 0 on fail |
The insert() method in version 0.28 would throw an error with the
{safe => 1} option, but newer versions silently return 0. Throwing an
error was a better design, because " or die
MongoDB::Database->last_error" is tedious to write, easily missed, and
prone to synchronization errors because the error is disconnected from
the origin. Using eval {} or try/catch gives more flexibility for
catching errors at various depths of scope and thus cleaner code.
The new remove(), update(), and ensure_index() 'safe' options seem to
have this same misfeature.
If there is some good reason why these operations cannot throw an
error, the Changes file should have noted this incompatible API change
because it will cause silent breakage of any code which was expecting
the error semantics.
Thanks,
Eric