Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored flow error checks #1953

Merged
merged 6 commits into from Mar 13, 2019
Merged
Diff settings

Always

Just for now

Copy path View file
@@ -556,5 +556,14 @@ function handleCreateAliasError<T>(
return 1;
}

if (error instanceof ERRORS.WildcardNotAllowed) {
output.error(
`Custom suffixes are only allowed for domains in ${chalk.underline(
'zeit.world'
)}`
);
return 1;
}

return error;
}
Copy path View file
@@ -60,12 +60,7 @@ export default async function assignAlias(
prevDeployment.scale,
deployment.url
);
if (
result instanceof ERRORS.NotSupportedMinScaleSlots ||
result instanceof ERRORS.ForbiddenScaleMinInstances ||
result instanceof ERRORS.ForbiddenScaleMaxInstances ||
result instanceof ERRORS.InvalidScaleMinMaxRelation
) {
if (result instanceof Error) {
return result;
}

@@ -95,21 +90,7 @@ export default async function assignAlias(
if (alias.indexOf('.') !== -1 && !NOW_SH_REGEX.test(alias)) {
// Now the domain shouldn't be available and it might or might not belong to the user
const result = await setupDomain(output, client, alias, contextName);
if (
result instanceof ERRORS.DomainAlreadyExists ||
result instanceof ERRORS.DomainNotAvailable ||
result instanceof ERRORS.DomainNotFound ||
result instanceof ERRORS.DomainPermissionDenied ||
result instanceof ERRORS.DomainPurchasePending ||
result instanceof ERRORS.DomainServiceNotAvailable ||
result instanceof ERRORS.DomainVerificationFailed ||
result instanceof ERRORS.InvalidDomain ||
result instanceof ERRORS.SourceNotFound ||
result instanceof ERRORS.UnexpectedDomainPurchaseError ||
result instanceof ERRORS.DomainPaymentError ||
result instanceof ERRORS.UnsupportedTLD ||
result instanceof ERRORS.UserAborted
) {
if (result instanceof Error) {
return result;
}

@@ -126,19 +107,7 @@ export default async function assignAlias(
alias,
externalDomain
);
if (
record instanceof ERRORS.AliasInUse ||
record instanceof ERRORS.CantSolveChallenge ||
record instanceof ERRORS.DeploymentNotFound ||
record instanceof ERRORS.DomainConfigurationError ||
record instanceof ERRORS.DomainPermissionDenied ||
record instanceof ERRORS.DomainsShouldShareRoot ||
record instanceof ERRORS.DomainValidationRunning ||
record instanceof ERRORS.InvalidAlias ||
record instanceof ERRORS.TooManyCertificates ||
record instanceof ERRORS.TooManyRequests ||
record instanceof ERRORS.InvalidDomain
) {
if (record instanceof Error) {
return record;
}

Copy path View file
@@ -37,16 +37,7 @@ export default async function createAlias(
alias,
!externalDomain
);
if (
cert instanceof ERRORS.CantSolveChallenge ||
cert instanceof ERRORS.DomainConfigurationError ||
cert instanceof ERRORS.DomainPermissionDenied ||
cert instanceof ERRORS.DomainsShouldShareRoot ||
cert instanceof ERRORS.DomainValidationRunning ||
cert instanceof ERRORS.TooManyCertificates ||
cert instanceof ERRORS.TooManyRequests ||
cert instanceof ERRORS.InvalidDomain
) {
if (cert instanceof Error) {
return cert;
}

@@ -26,21 +26,7 @@ export default async function upsertPathAlias(

if (!NOW_SH_REGEX.test(alias)) {
const domainInfo = await setupDomain(output, client, alias, contextName);
if (
domainInfo instanceof ERRORS.DomainAlreadyExists ||
domainInfo instanceof ERRORS.DomainNotAvailable ||
domainInfo instanceof ERRORS.DomainNotFound ||
domainInfo instanceof ERRORS.DomainPermissionDenied ||
domainInfo instanceof ERRORS.DomainPurchasePending ||
domainInfo instanceof ERRORS.DomainServiceNotAvailable ||
domainInfo instanceof ERRORS.DomainVerificationFailed ||
domainInfo instanceof ERRORS.InvalidDomain ||
domainInfo instanceof ERRORS.SourceNotFound ||
domainInfo instanceof ERRORS.UnexpectedDomainPurchaseError ||
domainInfo instanceof ERRORS.DomainPaymentError ||
domainInfo instanceof ERRORS.UnsupportedTLD ||
domainInfo instanceof ERRORS.UserAborted
) {
if (domainInfo instanceof Error) {
return domainInfo;
}

@@ -61,15 +47,7 @@ export default async function upsertPathAlias(
alias,
!externalDomain
);
if (
cert instanceof ERRORS.CantSolveChallenge ||
cert instanceof ERRORS.DomainConfigurationError ||
cert instanceof ERRORS.DomainPermissionDenied ||
cert instanceof ERRORS.DomainsShouldShareRoot ||
cert instanceof ERRORS.DomainValidationRunning ||
cert instanceof ERRORS.TooManyCertificates ||
cert instanceof ERRORS.TooManyRequests
) {
if (cert instanceof Error) {
return cert;
}

@@ -57,14 +57,7 @@ export default async function purchaseDomainIfAvailable(

output.print(eraseLines(1));
const result = await purchaseDomain(client, domain, price);
if (
result instanceof ERRORS.SourceNotFound ||
result instanceof ERRORS.DomainNotAvailable ||
result instanceof ERRORS.DomainServiceNotAvailable ||
result instanceof ERRORS.InvalidDomain ||
result instanceof ERRORS.UnexpectedDomainPurchaseError ||
result instanceof ERRORS.DomainPaymentError
) {
if (result instanceof Error) {
return result;
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.