Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Commit

Permalink
handing error message
Browse files Browse the repository at this point in the history
  • Loading branch information
simalexan committed Aug 18, 2017
1 parent 3429fee commit 53478aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bin/scotty.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ function cmd(console) {
if (!AWS.config.credentials)
return console.log(`Set AWS credentials first. Guide is available here: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html`)

if (!AWS.config.region)
if (!args.region) {
return getDefaultRegion()
.catch(() => {
if (args.force)
return saveDefaultRegion(args.region || 'us-east-1')
return 'us-east-1'

return inquirer.prompt([{
type: 'list',
Expand All @@ -152,8 +152,10 @@ function cmd(console) {
.then(saveDefaultRegion)
})
.then(region => beamUp(args, region, console))
}

return beamUp(args, AWS.config.region, console)
return saveDefaultRegion(args.region)
.then(() => beamUp(args, args.region, console))
}

function beamUp (args, region, console) {
Expand Down
2 changes: 2 additions & 0 deletions lib/scotty.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function createOrUpdateBucket(bucket, region, update, force, quiet, logger) {
if (err.code === 'BucketAlreadyExists')
err.message += '\n\nTry running the command with a new bucket name: \n scotty --bucket some-new-unique-name\n\nor change the name of your folder and re-run the same command.'

if (err.code === 'InvalidLocationConstraint')
err.message += '\n\nBucket already exists in a different region. Please change to: \n a) the correct region (using `-r region-name`) \n OR \n b) a different bucket name (using `-b bucket-name`)'
throw err
})
}
Expand Down

0 comments on commit 53478aa

Please sign in to comment.