aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/GlobalErrorStore.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-10-26 15:50:39 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2019-10-26 15:50:39 +0200
commit49e351d6ba03bf21543585d17eb4260516843978 (patch)
tree743344c53175aad988f0d725c7bb3c31a8465261 /src/stores/GlobalErrorStore.js
parentAttempt at fixing Travis conditional sed (diff)
downloadferdium-app-49e351d6ba03bf21543585d17eb4260516843978.tar.gz
ferdium-app-49e351d6ba03bf21543585d17eb4260516843978.tar.zst
ferdium-app-49e351d6ba03bf21543585d17eb4260516843978.zip
Extend debug information
Diffstat (limited to 'src/stores/GlobalErrorStore.js')
-rw-r--r--src/stores/GlobalErrorStore.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/stores/GlobalErrorStore.js b/src/stores/GlobalErrorStore.js
index 8bdafb68c..dbcc56606 100644
--- a/src/stores/GlobalErrorStore.js
+++ b/src/stores/GlobalErrorStore.js
@@ -5,14 +5,32 @@ import Request from './lib/Request';
5export default class GlobalErrorStore extends Store { 5export default class GlobalErrorStore extends Store {
6 @observable error = null; 6 @observable error = null;
7 7
8 @observable errors = [];
9
8 @observable response = {}; 10 @observable response = {};
9 11
10 constructor(...args) { 12 constructor(...args) {
11 super(...args); 13 super(...args);
12 14
15 window.onerror = this._handleConsoleError.bind(this);
16
17 const origConsoleError = console.error;
18 console.error = (...args) => {
19 this._handleConsoleError.call(this, args);
20 origConsoleError.apply(this, args);
21 }
22
13 Request.registerHook(this._handleRequests); 23 Request.registerHook(this._handleRequests);
14 } 24 }
15 25
26 _handleConsoleError(error, url, line) {
27 this.errors.push({
28 error,
29 url,
30 line
31 });
32 }
33
16 _handleRequests = action(async (request) => { 34 _handleRequests = action(async (request) => {
17 if (request.isError) { 35 if (request.isError) {
18 this.error = request.error; 36 this.error = request.error;
@@ -28,6 +46,17 @@ export default class GlobalErrorStore extends Store {
28 // this.actions.user.logout({ serverLogout: true }); 46 // this.actions.user.logout({ serverLogout: true });
29 } 47 }
30 } 48 }
49
50 this.errors.push({
51 request: {
52 result: request.result,
53 wasExecuted: request.wasExecuted,
54 method: request._method,
55 },
56 error: this.error,
57 response: this.response,
58 server: window.ferdi.stores.settings.app.server,
59 });
31 } else { 60 } else {
32 window.ferdi.stores.app.authRequestFailed = false; 61 window.ferdi.stores.app.authRequestFailed = false;
33 } 62 }