verdnatura-chat/app/views/ChangeAvatarView/submitHelpers.ts

15 lines
481 B
TypeScript
Raw Normal View History

2023-01-17 16:02:24 +00:00
import I18n from '../../i18n';
2023-01-18 20:11:25 +00:00
export const handleError = (e: any, action: string) => {
2023-01-17 16:02:24 +00:00
if (e.data && e.data.error.includes('[error-too-many-requests]')) {
throw new Error(e.data.error);
}
if (e.error && e.error === 'error-avatar-invalid-url') {
throw new Error(I18n.t(e.error, { url: e.details.url }));
}
if (I18n.isTranslated(e.error)) {
throw new Error(I18n.t(e.error));
}
throw new Error(I18n.t('There_was_an_error_while_action', { action: I18n.t(action) }));
};