mardi 26 mai 2015

Display global/misc error message to user

I'm trying to display error messages for the user in Ember. Is there a way to do this from Logger? I've read about the error substate, but I think that only displays when there's an error in a transition. Is there a way for me to set a property in the ApplicationController to the error message object (and thus display it in a template)? If there's an error in an AJAX call, or a bug, or some other issue, I want the user to be notified that something is awry.

The Coffeescript:

 Ember.Logger.error = (message, cause, stack) ->
  console.error(message, cause, stack) #show in console
  Raygun.send(new Error(message), null, { cause: cause, stack: stack }) #log error on server

  # how do I display the error message to user?, THIS DOESN'T WORK b/c "this" is undefined:
  @container.lookup('controller:main').set('errorObjetct', message)

I'm using Ember 1.11.1 in ember-cli.

Anyone have any tips on this?

Bryan




Aucun commentaire:

Enregistrer un commentaire