From 60837a0368de4ef28563bc2d64ffe918399b09e2 Mon Sep 17 00:00:00 2001 From: Matheus Fernandes Date: Mon, 8 May 2017 06:24:13 -0700 Subject: [PATCH] Show a nicer error if trying to buy a domain without a credit card --- lib/domains.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/domains.js b/lib/domains.js index a6da806..5e89295 100644 --- a/lib/domains.js +++ b/lib/domains.js @@ -8,6 +8,7 @@ const chalk = require('chalk') const Now = require('../lib') const isZeitWorld = require('./is-zeit-world') const { DNS_VERIFICATION_ERROR } = require('./errors') +const cmd = require('./utils/output/param') const domainRegex = /^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}$/ @@ -156,7 +157,11 @@ module.exports = class Domains extends Now { if ([400, 403, 500, 503].includes(res.status)) { const e = new Error() e.code = json.error.code - e.message = json.error.message + if (json.error.code === 'source_not_found') { + e.message = `No credit cards found – please run ${cmd('now cc add')}` + } else { + e.message = json.error.message + } return bail(e) }