chores: Improve error

This commit is contained in:
Paulo Gustavo Veiga 2021-03-01 17:48:12 -08:00
parent c0887d46d3
commit 812f7437d1
3 changed files with 6 additions and 9 deletions

View File

@ -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();
}

View File

@ -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:

View File

@ -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: () => {