aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/GlobalErrorStore.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-11-25 10:49:34 +0100
committerLibravatar vantezzen <hello@vantezzen.io>2019-11-25 10:49:34 +0100
commitc3a8d26cf4d7ffe3642cdc962e51e367885a9c12 (patch)
tree34d8cf9c8311165a81542d035079a91aa09ff3a6 /src/stores/GlobalErrorStore.js
parentBump version number (diff)
parentBump version number (diff)
downloadferdium-app-5.4.0.tar.gz
ferdium-app-5.4.0.tar.zst
ferdium-app-5.4.0.zip
Merge branch 'develop'v5.4.0
Diffstat (limited to 'src/stores/GlobalErrorStore.js')
-rw-r--r--src/stores/GlobalErrorStore.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/stores/GlobalErrorStore.js b/src/stores/GlobalErrorStore.js
index 8bdafb68c..aacaa247f 100644
--- a/src/stores/GlobalErrorStore.js
+++ b/src/stores/GlobalErrorStore.js
@@ -5,14 +5,54 @@ 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 messages = [];
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 = (...errorArgs) => {
16 this._handleConsoleError.call(this, ['error', ...errorArgs]);
17 };
18
19 const origConsoleError = console.error;
20 window.console.error = (...errorArgs) => {
21 this._handleConsoleError.call(this, ['error', ...errorArgs]);
22 origConsoleError.apply(this, errorArgs);
23 };
24
25 const origConsoleLog = console.log;
26 window.console.log = (...logArgs) => {
27 this._handleConsoleError.call(this, ['log', ...logArgs]);
28 origConsoleLog.apply(this, logArgs);
29 };
30
31 const origConsoleInfo = console.info;
32 window.console.info = (...infoArgs) => {
33 this._handleConsoleError.call(this, ['info', ...infoArgs]);
34 origConsoleInfo.apply(this, infoArgs);
35 };
36
13 Request.registerHook(this._handleRequests); 37 Request.registerHook(this._handleRequests);
14 } 38 }
15 39
40 _handleConsoleError(type, error, url, line) {
41 if (typeof type === 'object' && type.length && type.length >= 1) {
42 this.messages.push({
43 type: type[0],
44 info: type,
45 });
46 } else {
47 this.messages.push({
48 type,
49 error,
50 url,
51 line,
52 });
53 }
54 }
55
16 _handleRequests = action(async (request) => { 56 _handleRequests = action(async (request) => {
17 if (request.isError) { 57 if (request.isError) {
18 this.error = request.error; 58 this.error = request.error;
@@ -28,6 +68,18 @@ export default class GlobalErrorStore extends Store {
28 // this.actions.user.logout({ serverLogout: true }); 68 // this.actions.user.logout({ serverLogout: true });
29 } 69 }
30 } 70 }
71
72 this.messages.push({
73 type: 'error',
74 request: {
75 result: request.result,
76 wasExecuted: request.wasExecuted,
77 method: request._method,
78 },
79 error: this.error,
80 response: this.response,
81 server: window.ferdi.stores.settings.app.server,
82 });
31 } else { 83 } else {
32 window.ferdi.stores.app.authRequestFailed = false; 84 window.ferdi.stores.app.authRequestFailed = false;
33 } 85 }