marionettejs/backbone.marionette

Better error messages

Open

#2.795 geöffnet am 28. Okt. 2015

Auf GitHub ansehen
 (9 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (1.294 Forks)batch import
discussionhelp wanted

Repository-Metriken

Stars
 (7.085 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 34m) (1 gemergte PR in 30 T)

Beschreibung

When I'm using Marionette, I'll occasionally make errors such as accessing a region that doesn't exist e.g.

var MyView = Marionette.LayoutView.extend({
  regions: {
    main: '.main-hook'
  },

  onRender: function() {
    this.showChildView('layout', someView());
  }
});

var view = new MyView();
view.getChildView('layout');

The exception I get comes from inside Marionette as a Cannot read property currentView of undefined or this.getRegion(..) is undefined. While I can chase the stacktrace back to find out the exact issue, it would be much better if I could get the following error:

LayoutError: 'layout' is not a region on MyView. The available regions are: 'main'

This is just to illustrate my point - if we have the information on why something isn't going to work we should tell the developer to save them time.

Contributor Guide