             key: channelKey
             roles: channelRolesForCreation
           rest.POST '/channels', channel, (error, response, body) ->
-            if error
-              deferred.reject 'Error on creating channel: ' + error
+            if error?
+              deferred.reject "Error on creating channel: #{error}"
             else if response.statusCode is 201
               deferred.resolve body
             else
               humanReadable = JSON.stringify body, null, 2
-              deferred.reject 'Problem on creating channel: ' + humanReadable
+              deferred.reject "Problem on creating channel: #{humanReadable}"
     deferred.promise
 
   allInventoryEntries: (rest, queryString) ->
     deferred = Q.defer()
     rest.PAGED '/inventory?#{queryString}', (error, response, body) ->
-      if error
+      if error?
         deferred.reject "Error on fetching all inventory entries: #{error}"
       else
         if response.statusCode is 200

    entry =
      sku: sku
      quantityOnStock: parseInt(quantity)
    entry.expectedDelivery = expectedDelivery if expectedDelivery
    if channelId
      entry[CHANNEL_REF_NAME] =
        typeId: 'channel'
        id: channelId


  match: (s) ->
    _.find @existingInventoryEntries, (entry) ->
      if entry.sku is s.sku
        if _.has(entry, CHANNEL_REF_NAME) and _.has(s, CHANNEL_REF_NAME)
          entry[CHANNEL_REF_NAME].id is s[CHANNEL_REF_NAME].id
        else
          not _.has(s, CHANNEL_REF_NAME)

  createOrUpdate: (inventoryEntries, callback) ->
    if _.size(inventoryEntries) is 0
