         fromDate: fromDate,
         toDate: toDate)
       .then (response) ->
+        if response.error?
+          console.error(new Error(response.error))
         progress += 1
         ladda.setProgress(progress / ranges.length)
         response
-      .catch ->
+      .catch (err) ->
+        console.error(err)
         showAlert('danger', 'Server Error', 'Failed to get weekly charts.')
         ladda.stop()
   .then (charts) ->

  new Promise (resolve, reject) ->
    $.getJSON(url, params)
    .done (result) -> resolve(result)
    .fail (jqxhr, textStatus, error) -> reject(jqxhr)


setDefaults = (params) ->

    unless failedWeeksArray.length > 0
      navbarCollapsedState('add')
  .catch (err) ->
    console.error(err)
    if err.message.indexOf('error code 6') > -1
      # No user with that name was found.
      $username = $('#username')
      $username.parent().addClass('has-error').addClass('has-feedback')
