Permalink
Browse files

Handle errors.

  • Loading branch information...
1 parent ed98b46 commit dd403b47c91661c10237f363472e0f574c3dfaa2 @cmeiklejohn cmeiklejohn committed Feb 7, 2013
@@ -1524,4 +1524,4 @@ rect {
margin: 0 auto;
float: none;
}
-}
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -45,12 +45,28 @@ minispade.register('controllers', function() {
RiakCsControl.UsersNewController = Ember.ObjectController.extend({
createUser: function() {
var transaction = this.get('content.transaction');
- transaction.commit();
+ var content = this.get('content');
// Handle the success case, once the record is confirmed,
// materialize the record by forcing a load again (unfortunate)
// and redirect back to the main page.
- this.get('content').addObserver('id', this, 'viewUsers');
+ content.addObserver('id', this, 'viewUsers');
+
+ // Handle error states.
+ //
+ content.one('becameError', function() {
+ this.set('errorState', true);
+ });
+
+ content.one('becameInvalid', function() {
+ this.set('errorState', true);
+ });
+
+ content.one('becameClean', function() {
+ this.set('errorState', false);
+ });
+
+ transaction.commit();
},
viewUsers: function(user) {
@@ -1,4 +1,7 @@
<section class="constrained smaller info">
+ {{#if controller.errorState}}
+ <div class="notification red">An error occurred. Please try your request again later.</div>
+ {{/if}}
<div class="block-container smaller white left">
<h1 class="title">Create User</h1>

0 comments on commit dd403b4

Please sign in to comment.