Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loud save error #239

Merged
merged 2 commits into from
Oct 26, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
});