chore: Review fix
This commit is contained in:
@@ -215,10 +215,18 @@ export default {
|
||||
);
|
||||
} catch (error) {
|
||||
if (error instanceof DuplicateContactException) {
|
||||
if (error.data.includes('email')) {
|
||||
useAlert(this.$t('CONTACT_FORM.FORM.EMAIL_ADDRESS.DUPLICATE'));
|
||||
} else if (error.data.includes('phone_number')) {
|
||||
useAlert(this.$t('CONTACT_FORM.FORM.PHONE_NUMBER.DUPLICATE'));
|
||||
const detail = error.contactErrorDetail;
|
||||
if (detail) {
|
||||
useAlert(detail);
|
||||
} else {
|
||||
const invalidAttrs = Array.isArray(error.data) ? error.data : [];
|
||||
if (invalidAttrs.includes('email')) {
|
||||
useAlert(this.$t('CONTACT_FORM.FORM.EMAIL_ADDRESS.DUPLICATE'));
|
||||
} else if (invalidAttrs.includes('phone_number')) {
|
||||
useAlert(this.$t('CONTACT_FORM.FORM.PHONE_NUMBER.DUPLICATE'));
|
||||
} else {
|
||||
useAlert(this.$t('CONTACT_FORM.ERROR_MESSAGE'));
|
||||
}
|
||||
}
|
||||
} else if (error instanceof ExceptionWithMessage) {
|
||||
useAlert(error.data);
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
export class DuplicateContactException extends Error {
|
||||
static DEFAULT_MESSAGE = 'DUPLICATE_CONTACT';
|
||||
|
||||
constructor(data) {
|
||||
super('DUPLICATE_CONTACT');
|
||||
super(DuplicateContactException.DEFAULT_MESSAGE);
|
||||
this.data = data;
|
||||
this.name = 'DuplicateContactException';
|
||||
}
|
||||
|
||||
/** Server or client may assign `message` after construction; otherwise still DEFAULT_MESSAGE. */
|
||||
get contactErrorDetail() {
|
||||
return this.message === DuplicateContactException.DEFAULT_MESSAGE
|
||||
? null
|
||||
: this.message;
|
||||
}
|
||||
}
|
||||
export class ExceptionWithMessage extends Error {
|
||||
constructor(data) {
|
||||
|
||||
Reference in New Issue
Block a user