           reject "Insufficient arguments. Need either URL, or all of: data, type, md5sum and filename"
 
         if url?
-          downloaded = @_getRemoteMedia url
+          @_getRemoteMedia url
             .then @writeMedia.bind @
-          resolve downloaded
+            .then resolve
+            .error (error) =>
+              console.error red "Error downloading file: #{url}\n", error
+              reject error
         else if @media[md5sum]?
           log "using existing media file: #{filename}, #{@media[md5sum].link}"
           resolve

          debug 'url', url
          mediaLoaded.push @writeMedia {url}

      # once all media has been loaded
      Promise.all mediaLoaded
        .then (media) => # replace media urls in article
          for file in media
            article.content = article.content.replace new RegExp(escapeStringRegexp file.origUrl), file.url
          media
        .then (media) => # write article to wordpress
          featuredImage = media[0]
          data =
            post_type:    'post'
            post_status:  'publish'

          log "writing media file: #{file.name}, #{file.type}"
          @wordpress.uploadFile file, (error, result) ->
            if error
              console.error red "filename: ", file.name, "\n", error
              reject error
            else
              result.origUrl = origUrl
