fix: Add meaningful alert error message if file upload fails (#3093)

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Sivin Varghese 2021-09-29 13:00:08 +05:30 committed by GitHub
parent a8f6eebd66
commit 6f6bb91823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -347,7 +347,10 @@ export default {
await this.$store.dispatch('sendMessage', messagePayload); await this.$store.dispatch('sendMessage', messagePayload);
this.$emit('scrollToMessage'); this.$emit('scrollToMessage');
} catch (error) { } catch (error) {
// Error const errorMessage =
error?.response?.data?.error ||
this.$t('CONVERSATION.MESSAGE_ERROR');
this.showAlert(errorMessage);
} }
this.hideEmojiPicker(); this.hideEmojiPicker();
} }

View file

@ -84,6 +84,7 @@
"CHANGE_AGENT": "Conversation Assignee changed", "CHANGE_AGENT": "Conversation Assignee changed",
"CHANGE_TEAM": "Conversation team changed", "CHANGE_TEAM": "Conversation team changed",
"FILE_SIZE_LIMIT": "File exceeds the {MAXIMUM_FILE_UPLOAD_SIZE} attachment limit", "FILE_SIZE_LIMIT": "File exceeds the {MAXIMUM_FILE_UPLOAD_SIZE} attachment limit",
"MESSAGE_ERROR": "Unable to send this message, please try again later",
"SENT_BY": "Sent by:", "SENT_BY": "Sent by:",
"ASSIGNMENT": { "ASSIGNMENT": {
"SELECT_AGENT": "Select Agent", "SELECT_AGENT": "Select Agent",

View file

@ -155,6 +155,7 @@ const actions = {
}, },
sendMessage: async ({ commit }, data) => { sendMessage: async ({ commit }, data) => {
// eslint-disable-next-line no-useless-catch
try { try {
const pendingMessage = createPendingMessage(data); const pendingMessage = createPendingMessage(data);
commit(types.default.ADD_MESSAGE, pendingMessage); commit(types.default.ADD_MESSAGE, pendingMessage);
@ -164,7 +165,7 @@ const actions = {
status: MESSAGE_STATUS.SENT, status: MESSAGE_STATUS.SENT,
}); });
} catch (error) { } catch (error) {
// Handle error throw error;
} }
}, },