Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

issue #9 handle repo 404

- invoke onRepositoryError event on non-200 status
  • Loading branch information...
commit 67b1b622fb26bcb5c6b69236475143a80cfc1332 1 parent 1fc0b9b
@rviscomi authored
Showing with 13 additions and 5 deletions.
  1. +2 −0  README.md
  2. +11 −5 red-dwarf.js
View
2  README.md
@@ -62,6 +62,8 @@ Event handlers are defined by including functions keyed by the respective event
* **onRepositoryLoaded** Fired after successfully loading repository info from the GitHub API.
* `data` The data object returned by GitHub.
+* **onRepositoryError** Fired after unsuccessfully loading repository info from the GitHub API.
+ * `message` The error message returned by GitHub.
* **onCacheLoaded** Fired after successfully loading the JSON cache file.
* **onStargazersUpdated** Fired after processing a chunk of at most 100 repository stargazers.
* `num_stargazers` The number of stargazers processed so far.
View
16 red-dwarf.js
@@ -1,11 +1,11 @@
/**!
- * red dwarf v1.0.4
+ * red dwarf v1.0.5
* https://github.com/rviscomi/red-dwarf
*
* Copyright 2012 Rick Viscomi
* Released under the MIT License.
*
- * Date: October 5, 2012
+ * Date: October 12, 2012
*/
(function () {
@@ -49,6 +49,7 @@
}
/* Event hooks. */
+ this.onRepositoryError = options.onRepositoryError || function () {};
this.onRepositoryLoaded = options.onRepositoryLoaded || function () {};
this.onCacheLoaded = options.onCacheLoaded || function () {};
this.onStargazersUpdated = options.onStargazersUpdated || function () {};
@@ -134,9 +135,14 @@
this.repository,
dataType: 'jsonp',
success: function (data) {
- that.num_stargazers = data.data.watchers; // TODO data.stargazers?
-
- that.onRepositoryLoaded(data.data);
+ if (data.meta.status === 200) {
+ that.num_stargazers = data.data.watchers; // TODO data.stargazers?
+
+ that.onRepositoryLoaded(data.data);
+ }
+ else {
+ that.onRepositoryError(data.data.message);
+ }
},
complete: onComplete
});
Please sign in to comment.
Something went wrong with that request. Please try again.