chore: Show error messages from server in agent APIs (#4055)

This commit is contained in:
Pranav Raj S
2022-02-23 20:18:20 +05:30
committed by GitHub
parent 1ca1b4d36b
commit 85f19fa25a

View File

@@ -127,11 +127,16 @@ export default {
this.showAlert(this.$t('AGENT_MGMT.ADD.API.SUCCESS_MESSAGE'));
this.onClose();
} catch (error) {
const {
response: { data: { error: errorResponse = '' } = {} } = {},
} = error;
let errorMessage = '';
if (error.response.status === 422) {
this.showAlert(this.$t('AGENT_MGMT.ADD.API.EXIST_MESSAGE'));
errorMessage = this.$t('AGENT_MGMT.ADD.API.EXIST_MESSAGE');
} else {
this.showAlert(this.$t('AGENT_MGMT.ADD.API.ERROR_MESSAGE'));
errorMessage = this.$t('AGENT_MGMT.ADD.API.ERROR_MESSAGE');
}
this.showAlert(errorResponse || errorMessage);
}
},
},