Add dictionary to map system to friendly error messages for purchase
During purchase, errors are not always meaningful and are easy to understand for the customers. Reasons might be that the backend doesn't send a well-formed mistake or that we don't have control over the error (e.g., when coming from Zuora). E.g., "last_name":["can't be blank"]
.
To provide the customers with more meaningful errors, we create a dictionary (i.e. a JavaScript object) that maps unfriendly/system to friendly errors. The dictionary will be used in follow-up implementation (see X Y Z).
One advantage of separating the dictionary from the error-handling implementation is that anyone could change it without knowing the internal implementation. Another advantage of the dictionary, is that it could further implement additional error codes, along with the unfriendly string, e.g.,
{
'an unfriendly error': 'a friendly error',
'unfriendly-error-code': 'a friendly error',
12345: 'a friendly error',
}
The dictionary will start with the following mapping:
Error (describes what happened, not user-facing) | Message to display (user-facing) |
---|---|
The Contract effective date should not be later than the term end date of the basic subscription. | An error occurred with your purchase because your group is currently linked to an expired subscription. Open a support ticket, and our support team will assist with a workaround. |
"last_name":["can't be blank"] | A full name in your profile is required to make a purchase. Check that the full name field in your user profile has both a first and last name, then retry the purchase. If the problem persists, contact support. |
Transaction declined.generic_decline - Your card was declined | Your card was declined. Contact your card issuer for more information or contact our sales team to use an alternative payment method. |
{"email"=>["has already been taken"]} | An error occurred with your purchase. We detected a Customers Portal account that matches your email address, but it has not been linked to your GitLab.com account. Follow the instructions to link your Customers Portal account, and retry the purchase. If the problem persists, contact support. |
Your card has insufficient funds. | Your card was declined due to insufficient funds. Make sure you have sufficient funds, then retry the purchase or use a different card. If the problem persists, contact support. |