Browse Source
Show a proper message for non-supported TLDs
master
Matheus Fernandes
8 years ago
No known key found for this signature in database
GPG Key ID: DD07CA4EA7B65C4F
3 changed files with
31 additions and
3 deletions
bin/domains/buy.js
lib/alias.js
lib/domains.js
@ -24,7 +24,17 @@ module.exports = async function({ domains, args, currentTeam, user }) {
elapsed = stamp ( )
let stopSpinner = wait ( ` Checking availability for ${ nameParam } ` )
const { price , period } = await domains . price ( name )
let price
let period
try {
const json = await domains . price ( name )
price = json . price
period = json . period
} catch ( err ) {
stopSpinner ( )
return error ( err . message )
}
const available = await domains . status ( name )
stopSpinner ( )
@ -539,14 +539,26 @@ module.exports = class Alias extends Now {
let elapsed = stamp ( )
const parsed = publicSuffixList . parse ( alias )
const pricePromise = domains . price ( parsed . domain )
const pricePromise = domains . price ( parsed . domain ) . catch ( ( ) => {
// Can be safely ignored
} )
const canBePurchased = await domains . status ( parsed . domain )
const aliasParam = param ( parsed . domain )
let price
let period
stopSpinner ( )
if ( canBePurchased ) {
const { price , period } = await pricePromise
try {
const json = await pricePromise
price = json . price
period = json . period
} catch ( err ) {
// Can be safely ignored
}
}
if ( canBePurchased && price && period ) {
const periodMsg = ` ${ period } yr ${ period > 1 ? 's' : '' } `
info (
` The domain ${ aliasParam } is ${ chalk . italic ( 'available' ) } to buy under ${ chalk . bold ( ( currentTeam && currentTeam . slug ) || user . username || user . email ) } ! ${ elapsed ( ) } `
@ -121,6 +121,12 @@ module.exports = class Domains extends Now {
const res = await this . _ fetch ( ` /domains/price? ${ query } ` )
const json = await res . json ( )
if ( res . status === 400 ) {
const e = new Error ( json . error . message )
e . code = json . error . code
return bail ( e )
}
if ( this . _ debug ) {
console . timeEnd ( ` > [debug] # ${ attempt } GET /domains/price? ${ query } ` )
}