Skip to content
Browse files

Refactoring the error handling in the github client.

  • Loading branch information...
1 parent ae26e92 commit 6835a5a96440a269cfab9b27a7f3bc8657f5b090 @vesln committed
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/github.js
View
10 lib/github.js
@@ -41,7 +41,9 @@ github.repos = function(username, cb) {
var repos = [];
github.request(url, function(err, response, body) {
- body || (body = []);
+ if (response.statusCode == 404) {
+ throw new Error('Oops. Invalid user.');
+ }
body.repositories.forEach(function(repo) {
repos.push(repo.name);
@@ -64,10 +66,8 @@ github.issues = function(username, repos, cb) {
var url = github.url('issues', { user: username, repo: repo });
github.request(url, function(err, response, body) {
- switch (response.statusCode) {
- case 404: return done(new Error('Invalid username or repository name.'));
- case 200: break;
- default: body = []
+ if (response.statusCode == 404) {
+ done(new Error('Oops. Invalid user or repo.'));
}
results[repo] = body.issues;
done(err);

0 comments on commit 6835a5a

Please sign in to comment.
Something went wrong with that request. Please try again.