Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add error handling to the API explorer

  • Loading branch information...
commit f6b625d1dbb974a5a942a3f6293e8add8560e638 1 parent 192d69f
@autarch autarch authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 share/api-explorer/js/Explorer.js
View
18 share/api-explorer/js/Explorer.js
@@ -81,6 +81,20 @@
return div.html();
};
+ var _errorTemplate =
+ '<h2>An Error Occurred</h2>' +
+ '<p>{{status}} {{error}}</p>';
+
+ R.prototype.displayError = function (xhr, error) {
+ var self = this;
+
+ var view = {
+ "status": xhr.status,
+ "error": error
+ };
+ $("#response-display").html( $.mustache( _errorTemplate, view ) );
+ };
+
return R;
}
)();
@@ -136,6 +150,10 @@
function (response, status, xhr) {
self._response.displayResponse( response, xhr );
}
+ ).fail(
+ function (xhr, status, error) {
+ self._response.displayError( xhr, error );
+ }
);
};
Please sign in to comment.
Something went wrong with that request. Please try again.