meilisearch / design-team

1 stars 0 forks source link

check and improve error messages #34

Closed chayaline closed 2 years ago

chayaline commented 2 years ago

Context

Error messages should be clear, concise and helpful

Resources

Current error messages:

export const getErrorMessage = (errorCode) => {
  switch (errorCode) {
    /* User login */
    case 'user_login_invalid':
      return 'User credentials are invalid'

    case 'user_not_verified':
      return 'User email not verified'

    /* User register */
    case 'user_creation_error':
      return 'Unable to create user, please try again'

    case 'user_email_exists':
      return 'Email already exists'

    case 'user_email_invalid':
      return 'Email format is invalid'

    case 'registration_not_allowed':
      return 'Email address is not allowed to create an account'

    case 'user_name_invalid':
      return 'Name format is invalid'

    case 'user_name_unchanged':
      return 'The new name should be different from the old one'

    case 'user_password_match_error':
      return 'New password and password confirmation do not match'

    case 'user_email_match_error':
      return 'Email address and email address confirmation do not match'

    case 'user_email_unchanged':
      return 'The new email should be different from the old one'

    case 'user_password_invalid':
      return 'Password format is invalid'

    case 'user_password_unchanged':
      return 'The new password should be different from the current one'

    case 'password_token_expired':
      return "Password token doesn't exist or has expired"

    /* User deletion */
    case 'user_deletion_error':
      return 'Unable to delete user'

    case 'user_deletion_has_project':
      return 'Unable to delete user because at least one active project has been found'

    case 'user_deletion_has_item_subscription':
      return 'Unable to delete user because the subscription is not empty'

    /* Account */
    case 'user_password_error':
      return 'Password is invalid'

    case 'confirm_text_invalid':
      return 'Please type "delete my account" in the confirmation field'

    /* Projects */
    case 'project_create_name_exists':
      return 'Project name already exists'

    case 'project_name_invalid':
      return 'Project name is invalid'

    case 'project_payment_method_missing':
      return 'You need to add a payment method in the billing settings'

    case 'project_billing_address_missing':
      return 'You need to add a billing address in the billing settings'

    case 'project_version_missing':
      return 'You need to select a version'

    case 'project_create_error':
      return 'Unable to create project, please try again'

    case 'project_not_found':
      return 'Project not found'

    case 'project_update_error':
      return 'Unable to update project'

    case 'project_update_name_exists':
      return 'Project name already exists'

    case 'project_update_name_invalid':
      return 'Project name is invalid'

    case 'project_name_mismatch':
      return 'Project name does not match'

    case 'project_delete_error':
      return 'Unable to delete project'

    /* General */
    case 'unauthorized':
      return 'Unauthorized request'

    case 'not_found':
      return 'Not found'

    case 'form_invalid':
      return 'Please check the form'

    default:
      return 'Unexpected error, please try again'
  }
}

export default getErrorMessage