Browse Source

Show a nicer error if trying to buy a domain without a credit card

master
Matheus Fernandes 8 years ago
parent
commit
60837a0368
No known key found for this signature in database GPG Key ID: DD07CA4EA7B65C4F
  1. 7
      lib/domains.js

7
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)
}

Loading…
Cancel
Save