Skip to content

Commit

Permalink
fix: fixed error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
YuryShkoda committed Sep 8, 2020
1 parent 098d7fc commit a4e99d9
Showing 1 changed file with 62 additions and 38 deletions.
100 changes: 62 additions & 38 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,21 @@ export async function buildServices(targetName) {
)
)
.catch((err) => {
const body = JSON.parse(err.body)
const message = body.message || ''
if (err.hasOwnProperty('body')) {
const body = JSON.parse(err.body)
const message = body.message || ''

console.log(
chalk.redBright(
'An error has occurred when building services.',
message
console.log(
chalk.redBright(
'An error has occurred when building services.',
message
)
)
)
} else {
console.log(
chalk.redBright('An error has occurred when building services.', err)
)
}
})
}

Expand All @@ -75,15 +81,21 @@ export async function compileServices(targetName) {
)
)
.catch((err) => {
const body = JSON.parse(err.body)
const message = body.message || ''
if (err.hasOwnProperty('body')) {
const body = JSON.parse(err.body)
const message = body.message || ''

console.log(
chalk.redBright(
'An error has occurred when building services.',
message
console.log(
chalk.redBright(
'An error has occurred when building services.',
message
)
)
)
} else {
console.log(
chalk.redBright('An error has occurred when building services.', err)
)
}
})
}

Expand All @@ -97,20 +109,26 @@ export async function deployServices(targetName, isForced) {
)
)
.catch((err) => {
const body = JSON.parse(err.body)
const message = body.message || ''
const status = err.status
if (err.hasOwnProperty('body')) {
const body = JSON.parse(err.body)
const message = body.message || ''
const status = err.status

console.log(
chalk.redBright(
'An error has occurred when building services.',
`${message}${
status === 409
? '\nIf you still want to deploy, use force flag (-f) after target name.'
: ''
}`
console.log(
chalk.redBright(
'An error has occurred when building services.',
`${message}${
status === 409
? '\nIf you still want to deploy, use force flag (-f) after target name.'
: ''
}`
)
)
)
} else {
console.log(
chalk.redBright('An error has occurred when deploying services.', err)
)
}
})
}

Expand Down Expand Up @@ -150,20 +168,26 @@ export async function compileBuildDeployServices(targetName, isForced) {
)
)
.catch((err) => {
const body = JSON.parse(err.body)
const message = body.message || ''
const status = err.status
if (err.hasOwnProperty('body')) {
const body = JSON.parse(err.body)
const message = body.message || ''
const status = err.status

console.log(
chalk.redBright(
'An error has occurred when building services.',
`${message}${
status === 409
? '\nIf you still want to deploy, use force flag (-f) after target name.'
: ''
}`
console.log(
chalk.redBright(
'An error has occurred when building services.',
`${message}${
status === 409
? '\nIf you still want to deploy, use force flag (-f) after target name.'
: ''
}`
)
)
)
} else {
console.log(
chalk.redBright('An error has occurred when building services.', err)
)
}
})
}

Expand Down

0 comments on commit a4e99d9

Please sign in to comment.