From 812f7437d1bbc800c0b8245136f84ea7dbf1f608 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 1 Mar 2021 17:48:12 -0800 Subject: [PATCH] chores: Improve error --- .../webapp/src/classes/client/mock-client/index.ts | 2 +- .../webapp/src/classes/client/rest-client/index.ts | 11 ++++------- .../src/components/maps-page/maps-list/index.tsx | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/webapp/src/classes/client/mock-client/index.ts b/packages/webapp/src/classes/client/mock-client/index.ts index c9646ec7..8a32bc79 100644 --- a/packages/webapp/src/classes/client/mock-client/index.ts +++ b/packages/webapp/src/classes/client/mock-client/index.ts @@ -104,7 +104,7 @@ class MockClient implements Client { perm = perm.concat(permissions); this.permissionsByMap.set(id, perm); - console.log(`Message ${message}`); + console.debug(`Message ${message}`); return Promise.resolve(); } diff --git a/packages/webapp/src/classes/client/rest-client/index.ts b/packages/webapp/src/classes/client/rest-client/index.ts index 87f8dcc5..aa62bc75 100644 --- a/packages/webapp/src/classes/client/rest-client/index.ts +++ b/packages/webapp/src/classes/client/rest-client/index.ts @@ -347,9 +347,6 @@ export default class RestClient implements Client { success(maps); }) .catch((error) => { - console.log('Maps List Error=>'); - console.log(error); - const response = error.response; const errorInfo = this.parseResponseOnError(response); reject(errorInfo); @@ -369,9 +366,7 @@ export default class RestClient implements Client { success(); }) .catch((error) => { - console.log(error); - const response = error.response; - const errorInfo = this.parseResponseOnError(response); + const errorInfo = this.parseResponseOnError(error.response); reject(errorInfo); }); }; @@ -500,11 +495,13 @@ export default class RestClient implements Client { // eslint-disable-next-line @typescript-eslint/no-explicit-any private parseResponseOnError = (response: any): ErrorInfo => { + console.error("Backend error=>"); + console.error(response.data); + let result: ErrorInfo | undefined; if (response) { const status: number = response.status; const data = response.data; - console.log(data); switch (status) { case 401: diff --git a/packages/webapp/src/components/maps-page/maps-list/index.tsx b/packages/webapp/src/components/maps-page/maps-list/index.tsx index 3bf1526f..e7ea7043 100644 --- a/packages/webapp/src/components/maps-page/maps-list/index.tsx +++ b/packages/webapp/src/components/maps-page/maps-list/index.tsx @@ -344,7 +344,7 @@ export const MapsList = (props: MapsListProps): React.ReactElement => { } console.debug(`Starred value map?.starred: ${map?.starred}`); - return client.updateStarred(id, !map?.starred); + return client.updateStarred(id, !(map?.starred)); }, { onSuccess: () => {