Skip to content

Commit

Permalink
Merge pull request #239 from Gaurav0/loud_save_error
Browse files Browse the repository at this point in the history
Loud save error
  • Loading branch information
Gaurav0 committed Oct 26, 2015
2 parents f425f2d + 769ffed commit d827241
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/gist/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default Ember.Route.extend({
} else {
this.send('setSaved');
}
});
}).catch((this.catchSaveError.bind(this)));
},

setSaved () {
Expand Down Expand Up @@ -84,10 +84,23 @@ export default Ember.Route.extend({
if (error && error.errors) {
let firstError = error.errors[0];
if (firstError.code === "unprocessable" && firstError.field === "forks") {
this.get('notify').info("You already own this gist.");
this.get('notify').error("You already own this gist.");
return;
}
}
this.get('notify').error("Something went wrong. The gist was not forked.");
throw error;
},

catchSaveError(error) {
if (error && error.errors) {
let firstError = error.errors[0];
if (firstError.code === "unprocessable") {
this.get('notify').error("The gist is invalid, and could not be saved.");
return;
}
}
this.get('notify').error("Something went wrong. The gist was not saved.");
throw error;
}
});

0 comments on commit d827241

Please sign in to comment.