Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Differentiate between error types when failing to load an exercise.
Browse files Browse the repository at this point in the history
Summary:
We used to only blame the user's internet.  But it seems sometimes it is
our fault too.  So now we differentitate between the different errors,
to be less confusing to users whose internet is not to blame, and to
help devs debug any particular issue based upon what our users report.

This is to fix: https://app.asana.com/0/27216215224639/71186369010999

Test Plan:
git grep warnTimeout
see that we weren't using this anywhere else.

on dev khan exercise files if they exist get served directly.  So to test we
can change the name so that it uses the exercises/handler_raw.py.
```
diff --git a/khan-exercise.js b/khan-exercise.js
index 8a9bcfd..eb048c3 100644
--- a/khan-exercise.js
+++ b/khan-exercise.js
@@ -2048,7 +2048,7 @@ function loadExercise(exerciseId, fileName) {

     debugLog("loadExercise start " + fileName);
     // Packing occurs on the server but at the same "exercises/" URL
-    $.get(urlBase + "exercises/" + fileName).done(function(data) {
+    $.ajax({url:urlBase + "exercises/Z" + fileName, timeout:1000}).done(function(data) {
         debugLog("loadExercise got " + fileName);

         // Get rid of any external scripts in data before we shove data
```
http://www.khanacademy.dev/math/arithmetic/addition-subtraction/basic_addition/e/addition_1
See 404 message.

Then in webapp:
```
diff --git a/exercises/handler_raw.py b/exercises/handler_raw.py
index 5aa90bd..03a1c8f 100644
--- a/exercises/handler_raw.py
+++ b/exercises/handler_raw.py
@@ -17,6 +17,8 @@ class RawExercise(request_handler.RequestHandler):
         would also cause problems for the a/b tests in
         exercises.file_experiments.
         """
+        import time
+        time.sleep(5000)
         path = self.request.path
         filename = urllib.unquote(path.split('/', 3)[3])
```
http://www.khanacademy.dev/math/arithmetic/addition-subtraction/basic_addition/e/addition_1
See timeout message.

Then in webapp:
```
diff --git a/exercises/handler_raw.py b/exercises/handler_raw.py
index 5aa90bd..9e1728a 100644
--- a/exercises/handler_raw.py
+++ b/exercises/handler_raw.py
@@ -17,6 +17,7 @@ class RawExercise(request_handler.RequestHandler):
         would also cause problems for the a/b tests in
         exercises.file_experiments.
         """
+        1/0
         path = self.request.path
         filename = urllib.unquote(path.split('/', 3)[3])
```

See the generic error message.

Then in javascript console do:
MathJax.Ajax.Require("some.js")

See the MathJax error message mentioning some.js.

Reviewers: emily, lauren

Subscribers: kevindangoor

Differential Revision: https://phabricator.khanacademy.org/D24180
  • Loading branch information
James Irwin committed Dec 17, 2015
1 parent 32eef88 commit f5d0d31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/kathjax-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ MathJax.Ajax.timeout = 60 * 1000;
MathJax.Ajax.loadError = (function( oldLoadError ) {
return function( file ) {
if (window.Khan) {
Khan.warnTimeout();
Khan.warnMathJaxError(file);
}
// Otherwise will receive unresponsive script error when finally finish loading
MathJax.Ajax.loadComplete = function( file ) { };
Expand Down
23 changes: 18 additions & 5 deletions khan-exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,21 @@ var Khan = {
"constructions": ["kmatrix"]
},

warnTimeout: function() {
$(Exercises).trigger("warning", [i18n._("Your internet might be too " +
"slow to see an exercise. Refresh the page or " +
warn: function(msg) {
$(Exercises).trigger("warning", [msg + i18n._(" Refresh the page or " +
"<a href='' id='warn-report'>report a problem</a>."),
false]);
// TODO(alpert): This event binding is kind of gross
$("#warn-report").click(function(e) {
e.preventDefault();
$("#report").click();
$(".report-issue-link").click();
});

},

warnMathJaxError: function(file) {
Khan.warn(i18n._("Sorry! There seems to be an issue with our math " +
"renderer loading the file: %(file)s.", {file: file}));
},

warnFont: function() {
Expand Down Expand Up @@ -2116,7 +2121,15 @@ function loadExercise(exerciseId, fileName) {
});
}).fail(function(xhr, status) {
debugLog("loadExercise err " + xhr.status + " " + fileName);
Khan.warnTimeout();
if (status === "timeout") {
Khan.warn(i18n._("Your internet might be too slow to see an " +
"exercise."));
} else if (xhr.status === 404) {
Khan.warn(i18n._("Oops! We can't seem to find this exercise."));
} else {
Khan.warn(i18n._("Oops! There was a problem loading this " +
"exercise."));
}
});

return promise;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f5d0d31

Please sign in to comment.