diff --git a/lib/client/doc.js b/lib/client/doc.js index 5fbd8b7cc..871c76a0b 100644 --- a/lib/client/doc.js +++ b/lib/client/doc.js @@ -1048,7 +1048,11 @@ Doc.prototype._hardRollback = function(err) { // This is critical error as it means that our doc is not in usable state // anymore, we should throw doc error. logger.error('Hard rollback doc fetch failed.', fetchError, inflightOp); - doc.emit('error', fetchError); + + doc.emit('error', new ShareDBError( + ERROR_CODE.ERR_HARD_ROLLBACK_FETCH_FAILED, + 'Hard rollback fetch failed: ' + fetchError.message + )); } if (err.code === ERROR_CODE.ERR_OP_SUBMIT_REJECTED) { diff --git a/lib/error.js b/lib/error.js index 85ccbda42..0715faf38 100644 --- a/lib/error.js +++ b/lib/error.js @@ -39,6 +39,7 @@ ShareDBError.CODES = { ERR_OP_NOT_ALLOWED_IN_PROJECTION: 'ERR_OP_NOT_ALLOWED_IN_PROJECTION', ERR_OP_SUBMIT_REJECTED: 'ERR_OP_SUBMIT_REJECTED', ERR_PENDING_OP_REMOVED_BY_OP_SUBMIT_REJECTED: 'ERR_PENDING_OP_REMOVED_BY_OP_SUBMIT_REJECTED', + ERR_HARD_ROLLBACK_FETCH_FAILED: 'ERR_HARD_ROLLBACK_FETCH_FAILED', ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM: 'ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM', ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM: 'ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM', ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT: 'ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT',