                 res.send {"ok":"0","errors":err.join()}
                 return remove_files files #cleanup after error
 
+
             #parse stack-trace file
             stackparser.parse_stack_trace_file files["stack-trace"].path, (err, stackdata) ->
                 if err?

                            # create crashreport collection
                            crashreport = {}
                            _(fields).each (v,k) -> crashreport[k] = v
                            crashreport.files = stored_files
                            # TODO: put attachment files into an array and replace /\./,'_'

                            #console.log "Crashreport: " + util.inspect(crashreport) #debug


        req.form.complete (err, fields, files) ->
            return res.send {"ok":"0","errors":err} if err? #form parsing/upload error

            #TODO: refactor validation & parsing stages into functions and run with async

            #validate data (TODO: wrap validation into one function)
            err = []
