web: Client: Fixed error handlers
This commit is contained in:
parent
cd63121dc7
commit
35de773d36
@ -113,10 +113,10 @@ class Confirm extends React.PureComponent {
|
||||
};
|
||||
activateConfirmUser(personalData, loginData, this.state.key, this.state.userId, EmployeeActivationStatus.Activated)
|
||||
.then(() => window.location.href = '/')
|
||||
.catch(e => {
|
||||
console.error("activate error", e);
|
||||
.catch(error => {
|
||||
console.error("activate error", error);
|
||||
this.setState({
|
||||
errorText: e.message,
|
||||
errorText: error,
|
||||
isLoading: false
|
||||
});
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ class ChangeEmail extends React.PureComponent {
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log('change client email error', e)
|
||||
window.location.href = `${window.location.origin}/error=${e.message}`;
|
||||
window.location.href = `${window.location.origin}/error=${e}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -100,9 +100,8 @@ class Form extends React.PureComponent {
|
||||
toastr.success(this.props.t("ChangePasswordSuccess"));
|
||||
history.push("/");
|
||||
})
|
||||
//.catch((res) => toastr.error(res.data))
|
||||
.catch(e => {
|
||||
toastr.error(this.props.t(`${e.message}`));
|
||||
.catch(error => {
|
||||
toastr.error(this.props.t(`${error}`));
|
||||
this.setState({ isLoading: false });
|
||||
});
|
||||
});
|
||||
@ -111,8 +110,8 @@ class Form extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { getConfirmationInfo, history } = this.props;
|
||||
getConfirmationInfo(this.state.key)
|
||||
.catch(e => {
|
||||
toastr.error(this.props.t(`${e.message}`));
|
||||
.catch(error => {
|
||||
toastr.error(this.props.t(`${error}`));
|
||||
history.push("/");
|
||||
});
|
||||
|
||||
|
@ -78,15 +78,6 @@ class Confirm extends React.PureComponent {
|
||||
logout();
|
||||
}*/
|
||||
|
||||
onError = (error) => {
|
||||
console.error("confirm error", error);
|
||||
this.setState({
|
||||
errorText: error,
|
||||
isLoading: false
|
||||
});
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
onSubmit = () => {
|
||||
this.setState({ isLoading: true }, () => {
|
||||
const { history, createConfirmUser, linkData } = this.props;
|
||||
@ -140,7 +131,13 @@ class Confirm extends React.PureComponent {
|
||||
toastr.success("User has been created successfully");
|
||||
return history.push('/');
|
||||
})
|
||||
.catch(this.onError);
|
||||
.catch((error) => {
|
||||
console.error("confirm error", error);
|
||||
this.setState({
|
||||
errorText: error,
|
||||
isLoading: false
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -64,8 +64,8 @@ class ConfirmRoute extends React.Component {
|
||||
break;
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
history.push(`${path}/error=${e.message}`);
|
||||
.catch(error => {
|
||||
history.push(`${path}/error=${error}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
export function checkResponseError(res) {
|
||||
if (res && res.data && res.data.error) {
|
||||
console.error(res.data.error);
|
||||
throw new Error(res.data.error.message);
|
||||
}
|
||||
}
|
@ -2,13 +2,11 @@ import axios from "axios";
|
||||
import Cookies from "universal-cookie";
|
||||
import history from "../../history";
|
||||
import { AUTH_KEY } from "../../helpers/constants.js";
|
||||
import { checkResponseError } from "../../helpers/utils";
|
||||
|
||||
const PREFIX = "api";
|
||||
const VERSION = "2.0";
|
||||
const baseURL = `${window.location.origin}/${PREFIX}/${VERSION}`;
|
||||
|
||||
//let authTokenRequest;
|
||||
|
||||
/**
|
||||
* @description axios instance for ajax requests
|
||||
@ -72,6 +70,13 @@ export function setAuthorizationToken(token) {
|
||||
}
|
||||
}
|
||||
|
||||
const checkResponseError = (res) => {
|
||||
if (res && res.data && res.data.error) {
|
||||
console.error(res.data.error);
|
||||
throw new Error(res.data.error.message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description wrapper for making ajax requests
|
||||
* @param {object} object with method,url,data etc.
|
||||
|
Loading…
Reference in New Issue
Block a user