Error explanation for unauthorized domain access (#1059)

This commit is contained in:
Tim Neutkens
2018-01-08 18:01:36 +01:00
committed by Leo Lamprecht
parent c4969b17dd
commit a6af5c8696
3 changed files with 22 additions and 7 deletions

View File

@@ -0,0 +1,9 @@
# Not authorized to access domain
#### Why This Error Occurred
You tried to add or update a domain's configuration, but you don't have permission to modify the domain.
#### Possible Ways to Fix It
If you or your team owns the domain, then you are most likely in the wrong context. Use `now switch` to select the team or user that owns the domain.

View File

@@ -1,4 +1,6 @@
// Ours
const error = require('../../../util/output/error')
const exit = require('../../../util/exit')
const Now = require('.')
module.exports = class DomainRecords extends Now {
@@ -90,9 +92,11 @@ module.exports = class DomainRecords extends Now {
new Error(body.error ? body.error.message : 'Unknown error')
)
} else if (res.status === 403) {
const err = new Error(`Not authorized to access the domain "${domain}"`)
err.userError = true
return bail(err)
console.error(error({
message: `Not authorized to access domain ${domain}`,
slug: 'unauthorized-domain'
}))
await exit(1)
} else if (res.status === 404) {
let err
@@ -125,9 +129,11 @@ module.exports = class DomainRecords extends Now {
const body = await res.json()
if (res.status === 403) {
const err = new Error(`Not authorized to access domain ${domain}`)
err.userError = true
return bail(err)
console.error(error({
message: `Not authorized to access domain ${domain}`,
slug: 'unauthorized-domain'
}))
await exit(1)
} else if (res.status === 404) {
let err

View File

@@ -729,7 +729,7 @@ module.exports = class Now extends EventEmitter {
)}.`
)
} else {
err = new Error(`Not authorized to access domain ${name}`)
err = new Error(`Not authorized to access domain ${name} http://err.sh/now-cli/unauthorized-domain`)
}
err.userError = true