         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) ->


hideAlert = ->
  $('#alert').addClass('hidden')


showAlert = (type, reason, message) ->

  new Promise (resolve, reject) ->
    $.getJSON(url, params)
    .done (result) -> resolve(result)
    .fail (jqxhr, textStatus, reason) ->
      message = jqxhr.responseJSON?.error ? reason
      error = new Error(message)
      error.jqxhr = jqxhr
      error.textStatus = textStatus
      error.reason = reason
      reject(error)


setDefaults = (params) ->
