Handle SQL errors in list() and count(), adhering to persistence.js "style"

This change allows to handle SQL errors using just one function, in the general style of persistence.js-The function passed to list() or count() will have a second argument (e.g. "error"). If the second arg is defined, an error occurred and it is described by the arg itself.