Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO : Flash success
toast.success(
"Vous êtes désormais inscrit, vous pouvez vous connecter !"
);
history.replace("/login");
} catch (error) {
const { violations } = error.response.data;
if (violations) {
violations.forEach(violation => {
apiErrors[violation.propertyPath] = violation.message;
});
setErrors(apiErrors);
}
toast.error("Des erreurs dans votre formulaire !");
}
};
.catch((error) => {
if (error) {
toast.error(Messages.LoadFailure);
}
// No reader found
if (files.length === 1) {
this.setState({ file: files[0] });
} else {
this.setState({ file: null });
}
});
}
const { code } = await response.json();
const ERROR_USERNAME_EXISTS = 100;
const ERROR_EMAIL_EXISTS = 200;
const ERROR_SERVER_ERROR = 400;
this.setState({ loading: false });
switch (code) {
case ERROR_USERNAME_EXISTS:
this.setState({ usernameError: 'Username already exists' });
return;
case ERROR_EMAIL_EXISTS:
this.setState({ emailError: 'Email already exists' });
return;
case ERROR_SERVER_ERROR:
toast.error('Failed to create account. Please contact an administrator.');
return;
default:
toast.error('Failed to create account. Please contact an administrator.');
return;
}
} else {
this.setState({ registered: true, loading: false });
}
} catch (err) {
toast.error('Failed to create account. Please contact an administrator.');
console.error(err);
}
}
}).catch(error => {
if (action.meta && action.meta.errorMessage) {
toast.error(action.meta.errorMessage);
}
return Promise.reject(error);
});
};
ipcRenderer.on(events.APP_ERROR, () => {
this.setState(prev => ({
isLoading: false,
formDisabled: false,
exportDisabled: !(prev.schema && prev.mutations && prev.queries)
}));
toast.error(`Could not connect to database.
Please check your connection
string and try again`);
});
mutationRendering = (data, error) => {
const key = this.props.service ? "updateService" : "newService"
if (data && data[key] && data[key].success) {
toast.success(`service ${this.props.service ? "updated" : "added"}`)
this.props.history.push('/')
}
if (error) {
if (data)
toast.error(data[key].error)
else
toast.error(error.message)
}
}
render() {
.catch(error => {
dispatch({
type: REGISTRATION_FAILURE
})
toast.error(error.message, {
position: toast.POSITION.BOTTOM_RIGHT
})
})
}
async _onClick(apiCall) {
try {
await apiCall();
} catch (err) {
toast.error(err.message);
}
}
}
err => {
if (err) {
toast.error(
<div>
Instance featching detail error: <br> {err}
</div>
);
}
}
);
saveValidate = () => {
const { startDate, endDate, title, markers } = this.state
if (!startDate || !endDate) {
toast.error("Date not provided", {
position: toast.POSITION.BOTTOM_RIGHT
})
return false
}
if (title === "") {
toast.error("Title not provided", {
position: toast.POSITION.BOTTOM_RIGHT
})
return false
}
if (!markers.length) {
toast.error("Set at least 1 checkpoint", {
position: toast.POSITION.BOTTOM_RIGHT
})
return false
}
return true
}