Skip to content

Commit

Permalink
fix: throw correct pouchdb error in pull, push and sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Terreii authored and gr2m committed Apr 12, 2020
1 parent 7560124 commit f27afc5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/pull.js
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
module.exports = pull

var Promise = require('lie')
var errors = require('pouchdb-errors')

var toId = require('./utils/to-id')

Expand All @@ -12,7 13,6 @@ var toId = require('./utils/to-id')
*/
function pull (state, docsOrIds) {
var pulledObjects = []
var errors = state.db.constructor.Errors

return Promise.resolve(state.remote)

Expand All @@ -25,7 25,8 @@ function pull (state, docsOrIds) {
}

if (docsOrIds && docsOrIds.filter(Boolean).length !== docsOrIds.length) {
return Promise.reject(errors.NOT_AN_OBJECT)
reject(errors.NOT_AN_OBJECT)
return
}

var replication = state.db.replicate.from(remote, {
Expand Down
5 changes: 3 additions & 2 deletions lib/push.js
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
module.exports = push

var Promise = require('lie')
var errors = require('pouchdb-errors')

var toId = require('./utils/to-id')

Expand All @@ -13,7 14,6 @@ var toId = require('./utils/to-id')

function push (state, docsOrIds) {
var pushedObjects = []
var errors = state.db.constructor.Errors

return Promise.resolve(state.remote)

Expand All @@ -26,7 26,8 @@ function push (state, docsOrIds) {
}

if (docsOrIds && docsOrIds.filter(Boolean).length !== docsOrIds.length) {
return Promise.reject(errors.NOT_AN_OBJECT)
reject(errors.NOT_AN_OBJECT)
return
}

var replication = state.db.replicate.to(remote, {
Expand Down
5 changes: 3 additions & 2 deletions lib/sync.js
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
module.exports = sync

var Promise = require('lie')
var errors = require('pouchdb-errors')

var toId = require('./utils/to-id')

Expand All @@ -12,7 13,6 @@ var toId = require('./utils/to-id')
*/
function sync (state, docsOrIds) {
var syncedObjects = []
var errors = state.db.constructor.Errors

return Promise.resolve(state.remote)

Expand All @@ -25,7 25,8 @@ function sync (state, docsOrIds) {
}

if (docsOrIds && docsOrIds.filter(Boolean).length !== docsOrIds.length) {
return Promise.reject(errors.NOT_AN_OBJECT)
reject(errors.NOT_AN_OBJECT)
return
}

var replication = state.db.sync(remote, {
Expand Down

0 comments on commit f27afc5

Please sign in to comment.