Skip to content

Commit

Permalink
Better error handling.
Browse files Browse the repository at this point in the history
Closes prose#113.
  • Loading branch information
michael committed Jun 23, 2012
1 parent ae6069a commit 8265cb5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion _includes/model.js
Expand Up @@ -156,7 +156,7 @@ function loadSite(user, repo, branch, path, cb) {

repo.getSha(branch, path, function(err, sha) {
repo.getTree(sha, function(err, tree) {
if (err) cb("Not a valid Jekyll repository.");
if (err) return cb("Not found");

var paths = _.compact(_.map(tree, function(file) {
return file.type === "tree" ? (path ? path + "/" : "")+ file.path : null;
Expand Down
1 change: 1 addition & 0 deletions _includes/routers/application.js
Expand Up @@ -48,6 +48,7 @@ routers.Application = Backbone.Router.extend({
// #example-user/example-repo/gh-pages/path/to
// #example-user/example-repo/gh-pages
posts: function(url) {
if (url.split('/').length < 3) return app.instance.notify('error', 'Not Found');
if (confirmExit()) {
app.instance.posts.apply(this, this.extractURL(url));
}
Expand Down
6 changes: 3 additions & 3 deletions _includes/views/application.js
Expand Up @@ -70,16 +70,16 @@ views.Application = Backbone.View.extend({

posts: function (user, repo, branch, path) {
loadSite(user, repo, branch, path, _.bind(function (err, data) {
if (err) return this.notify('error', 'Seems like the chosen repository is not a valid Jekyll site.');
if (err) return this.notify('error', 'The requested resource could not be found.');
this.header.render();
this.replaceMainView("posts", new views.Posts({ model: data, id: 'posts' }).render());
}, this));
},

post: function (user, repo, branch, path, file, preview) {
loadSite(user, repo, branch, path, _.bind(function (err, data) {
if (err) return this.notify('error', 'Seems like the chosen repository is not a valid Jekyll site.');

if (err) return this.notify('error', 'The requested resource could not be found.');
loadPost(user, repo, branch, path, file, _.bind(function (err, data) {
data.preview = preview;
this.header.render();
Expand Down

0 comments on commit 8265cb5

Please sign in to comment.