Explorar o código

handle exception in parsing retrieved json from aws

Brian Gough %!s(int64=10) %!d(string=hai) anos
pai
achega
ca1f1dc944
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      services/track-changes/app/coffee/MongoAWS.coffee

+ 5 - 2
services/track-changes/app/coffee/MongoAWS.coffee

@@ -74,8 +74,11 @@ module.exports = MongoAWS =
 
 		inputStream.on 'data', (line) ->
 				if line.length > 2
-					ops.push(JSON.parse(line))
-					sz += line.length 
+					try
+						ops.push(JSON.parse(line))
+					catch err
+						return callback(err)
+					sz += line.length
 				if ops.length >= MongoAWS.MAX_COUNT || sz >= MongoAWS.MAX_SIZE
 					inputStream.pause()
 					MongoAWS.handleBulk ops.slice(0), sz, () ->