aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/GlobalErrorStore.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/GlobalErrorStore.ts')
-rw-r--r--src/stores/GlobalErrorStore.ts27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/stores/GlobalErrorStore.ts b/src/stores/GlobalErrorStore.ts
index c42e9a4af..be86563d0 100644
--- a/src/stores/GlobalErrorStore.ts
+++ b/src/stores/GlobalErrorStore.ts
@@ -1,4 +1,5 @@
1import { observable, action, makeObservable } from 'mobx'; 1import { observable, action, makeObservable } from 'mobx';
2import { Response } from 'electron';
2import { Actions } from '../actions/lib/actions'; 3import { Actions } from '../actions/lib/actions';
3import { ApiInterface } from '../api'; 4import { ApiInterface } from '../api';
4import { Stores } from '../@types/stores.types'; 5import { Stores } from '../@types/stores.types';
@@ -11,12 +12,8 @@ interface Message {
11 message?: string; 12 message?: string;
12 status?: number; 13 status?: number;
13 }; 14 };
14 request?: { 15 request?: Request;
15 result: any; 16 response?: Response;
16 wasExecuted: any;
17 method: any;
18 };
19 response?: any;
20 server?: any; 17 server?: any;
21 info?: any; 18 info?: any;
22 url?: string; 19 url?: string;
@@ -28,7 +25,7 @@ export default class GlobalErrorStore extends TypedStore {
28 25
29 @observable messages: Message[] = []; 26 @observable messages: Message[] = [];
30 27
31 @observable response: object = {}; 28 @observable response: Response = {} as Response;
32 29
33 // TODO: Get rid of the @ts-ignores in this function. 30 // TODO: Get rid of the @ts-ignores in this function.
34 constructor(stores: Stores, api: ApiInterface, actions: Actions) { 31 constructor(stores: Stores, api: ApiInterface, actions: Actions) {
@@ -85,21 +82,15 @@ export default class GlobalErrorStore extends TypedStore {
85 } 82 }
86 } 83 }
87 84
88 @action _handleRequests = async (request: { 85 @action _handleRequests = async (request: Request): Promise<void> => {
89 isError: any;
90 error: { json: () => object | PromiseLike<object> };
91 result: any;
92 wasExecuted: any;
93 _method: any;
94 }): Promise<void> => {
95 if (request.isError) { 86 if (request.isError) {
96 this.error = request.error; 87 this.error = request.error;
97 88
98 if (request.error.json) { 89 if (request.error && request.error.json) {
99 try { 90 try {
100 this.response = await request.error.json(); 91 this.response = await request.error.json();
101 } catch { 92 } catch {
102 this.response = {}; 93 this.response = {} as Response;
103 } 94 }
104 if (this.error?.status === 401) { 95 if (this.error?.status === 401) {
105 window['ferdium'].stores.app.authRequestFailed = true; 96 window['ferdium'].stores.app.authRequestFailed = true;
@@ -111,8 +102,8 @@ export default class GlobalErrorStore extends TypedStore {
111 request: { 102 request: {
112 result: request.result, 103 result: request.result,
113 wasExecuted: request.wasExecuted, 104 wasExecuted: request.wasExecuted,
114 method: request._method, 105 method: request.method,
115 }, 106 } as Request,
116 error: this.error, 107 error: this.error,
117 response: this.response, 108 response: this.response,
118 server: window['ferdium'].stores.settings.app.server, 109 server: window['ferdium'].stores.settings.app.server,