added null check to where we insert elements into a project

This commit is contained in:
Henry Oswald 2014-10-31 10:37:44 +00:00
parent d428e7e5b4
commit 0f4d9771aa

View file

@ -71,6 +71,10 @@ sanitizeTypeOfElement = (elementType)->
return elementType return elementType
ProjectSchema.statics.putElement = (project_id, folder_id, element, type, callback)-> ProjectSchema.statics.putElement = (project_id, folder_id, element, type, callback)->
if !element?
e = new Error("no element passed to be inserted")
logger.err project_id:project_id, folder_id:folder_id, element:element, type:type, "failed trying to insert element as it was null"
return callback(e)
type = sanitizeTypeOfElement type type = sanitizeTypeOfElement type
this.findById project_id, (err, project)=> this.findById project_id, (err, project)=>
if err? if err?