From 49e351d6ba03bf21543585d17eb4260516843978 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sat, 26 Oct 2019 15:50:39 +0200 Subject: Extend debug information --- src/stores/GlobalErrorStore.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/stores/GlobalErrorStore.js') 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'; export default class GlobalErrorStore extends Store { @observable error = null; + @observable errors = []; + @observable response = {}; constructor(...args) { super(...args); + window.onerror = this._handleConsoleError.bind(this); + + const origConsoleError = console.error; + console.error = (...args) => { + this._handleConsoleError.call(this, args); + origConsoleError.apply(this, args); + } + Request.registerHook(this._handleRequests); } + _handleConsoleError(error, url, line) { + this.errors.push({ + error, + url, + line + }); + } + _handleRequests = action(async (request) => { if (request.isError) { this.error = request.error; @@ -28,6 +46,17 @@ export default class GlobalErrorStore extends Store { // this.actions.user.logout({ serverLogout: true }); } } + + this.errors.push({ + request: { + result: request.result, + wasExecuted: request.wasExecuted, + method: request._method, + }, + error: this.error, + response: this.response, + server: window.ferdi.stores.settings.app.server, + }); } else { window.ferdi.stores.app.authRequestFailed = false; } -- cgit v1.2.3-54-g00ecf