SERVER-8292 SERVER-7843 SERVER-7087 Make tojsonObject handle Error objects

Use the toString() method of Error (and derived) objects to convert them
to strings in tojson() and related functions.  These objects have no
enumerable properties, and so display as "{ }" if not handled specially.