|
38 | 38 | this.xhr.timeout = 1500; // time in milliseconds |
39 | 39 |
|
40 | 40 | self.onload = _ => { |
41 | | - if (self.status >= 200 && self.status < 400) { |
| 41 | + if (self.status >= 200 && self.status < 300) { |
42 | 42 | window.console.log(`Successfully called ${requestUrl}.`); |
43 | 43 | try { |
44 | 44 | var json = JSON.parse(self.responseText); |
|
50 | 50 | } |
51 | 51 | else { |
52 | 52 | window.console.log(`Error requesting ${requestUrl}. Response Status-Code is ${self.status}.`); |
| 53 | + let msg = self.status === 404 |
| 54 | + ? 'Invalid id? Gist API said "not found".' |
| 55 | + : `Error when fetching Gist. Gist API returned a ${self.status} response code.` |
53 | 56 | failure({ |
54 | 57 | status: 'error', |
55 | | - msg: `Error when fetching Gist. Gist API returned a ${self.status} response code.` |
| 58 | + msg: msg |
56 | 59 | }); |
57 | 60 | } |
58 | 61 | } |
59 | 62 | self.onerror = _ => { |
60 | 63 | window.console.log(`There was an error (of some sort) connecting to ${requestUrl}.`); |
61 | 64 | failure({ |
62 | 65 | status: 'error', |
63 | | - msg: 'Error when fetching Gist.' |
| 66 | + msg: 'Error when fetching Gist. Please try to reload.' |
64 | 67 | }); |
65 | 68 | }; |
66 | 69 | self.ontimeout = _ => { |
|
73 | 76 | if (response.components[i].id === 'brv1bkgrwx7q' && response.components[i].status !== 'operational') { |
74 | 77 | failure({ |
75 | 78 | status: 'error', |
76 | | - msg: 'The GitHub API is currently not fully operational. Sorry, but nothing we can do right now.' |
| 79 | + msg: 'The GitHub API is currently not fully operational. Sorry, but nothing we can do right now. Please check back later.' |
77 | 80 | }); |
78 | 81 | } |
79 | 82 | } |
80 | 83 | failure({ |
81 | 84 | status: 'error', |
82 | | - msg: 'API timeout error when fetching Gist.' |
| 85 | + msg: 'API timeout error when fetching Gist. Please try to reload.' |
83 | 86 | }); |
84 | 87 | } else { |
85 | 88 | failure({ |
86 | 89 | status: 'error', |
87 | | - msg: 'API timeout error when fetching Gist.' |
| 90 | + msg: 'API timeout error when fetching Gist. Please try to reload.' |
88 | 91 | }); |
89 | 92 | } |
90 | 93 | }, error => { |
91 | 94 | failure({ |
92 | 95 | status: 'error', |
93 | | - msg: 'API timeout error when fetching Gist.' |
| 96 | + msg: 'API timeout error when fetching Gist. Please try to reload.' |
94 | 97 | }); |
95 | 98 | }); |
96 | 99 | } else { |
97 | 100 | failure({ |
98 | 101 | status: 'error', |
99 | | - msg: 'API timeout error when fetching Gist AND when fetching the GitHub API status. Sorry, but nothing we can do right now.' |
| 102 | + msg: 'API timeout error when fetching Gist AND when fetching the GitHub API status. Please try to reload or check back later.' |
100 | 103 | }); |
101 | 104 | } |
102 | 105 | }; |
|
0 commit comments