             console.log "Fetching pack: #{packName}"
             context.requestPack packName, (error, flowNames) ->
               if error
-                console.log 'Failed fetching pack'
+                console.log '*** ERROR *** Failed fetching pack'
                 go error
               else
                 console.log 'Processing pack...'

page = webpage.create()

page.onResourceError = ({ url, errorString }) ->
  console.log "ERROR: #{url}: #{errorString}"

page.onConsoleMessage = (message) ->
  console.log message

waitFor = (test, onReady, timeout=3600000) ->
  startTime = new Date().getTime()
  condition = false
  retest = ->
    if (new Date().getTime() - startTime < timeout) and not condition
      console.log 'Polling...'
      condition = test()
    else
      if condition
        onReady()
        clearInterval interval
      else
        console.log 'ERROR: Timeout exceeded'
        phantom.exit 1 

  interval = setInterval retest, 2000

          window._phantom_started_ = yes
          runPacks (error) ->
            if error
              console.log '*** ERROR *** Error running packs: ' + JSON.stringify error
            else
              console.log 'Finished running all packs!'
            window._phantom_exit_ = yes
          no

    waitFor test, ->
      errors = page.evaluate -> window._phantom_errors_
      if errors
        console.log 'PHANTOM: *** ERROR *** One or more flows failed to complete: ' + JSON.stringify errors
        phantom.exit 1
      else
        console.log 'PHANTOM: Success! All flows ran to completion!'
        phantom.exit 0
  else
    console.log 'PHANTOM: *** ERROR *** Unable to access network.'
    phantom.exit 1


