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

Fix the handling of user errors #1959

Merged
merged 4 commits into from Mar 15, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+27 −2
Diff settings

Always

Just for now

Copy path View file
@@ -459,6 +459,13 @@ export default async function main(
error(message);
}

if (err.code === 'size_limit_exceeded') {
const { sizeLimit = 0 } = err;
const message = `File size limit exceeded (${bytes(sizeLimit)})`;
error(message);
return 1;
}

handleError(err);
return 1;
}
Copy path View file
@@ -421,7 +421,7 @@ async function sync({
'multiple_manifests'
];

if (err.code && print.includes(err.code)) {
if (err.code && print.includes(err.code) || err.name === 'JSONError') {
error(err.message);
return 1;
}
Copy path View file
@@ -18,7 +18,7 @@ import getMinFromArgs from '../util/scale/get-min-from-args';
import patchDeploymentScale from '../util/scale/patch-deployment-scale';
import waitVerifyDeploymentScale from '../util/scale/wait-verify-deployment-scale';
import { handleError } from '../util/error';
import { VerifyScaleTimeout } from '../util/errors-ts';
import { VerifyScaleTimeout, DeploymentTypeUnsupported } from '../util/errors-ts';
import {
DeploymentNotFound,
DeploymentPermissionDenied,
@@ -279,6 +279,11 @@ export default async function main(ctx) {
now.close();
return 1;
}
if (result instanceof DeploymentTypeUnsupported) {
output.error(`This region only accepts Serverless Docker Deployments.`);
now.close();
return 1;
}

console.log(
`${chalk.gray('>')} Scale rules for ${dcs
Copy path View file
@@ -535,6 +535,16 @@ export class DeploymentPermissionDenied extends NowError<
}
}

export class DeploymentTypeUnsupported extends NowError<'DEPLOYMENT_TYPE_UNSUPPORTED', {}> {
constructor() {
super({
code: 'DEPLOYMENT_TYPE_UNSUPPORTED',
meta: {},
message: `This region only accepts Serverless Docker Deployments`

This comment has been minimized.

Copy link
@juliangruber

juliangruber Mar 14, 2019

Author Contributor

is that always the case with this error?

This comment has been minimized.

Copy link
@leo

leo Mar 15, 2019

Member

@juliangruber I think we should say that only Now 2.0 deployments are supported?

This comment has been minimized.

Copy link
@leo

leo Mar 15, 2019

Member

Oh, nevermind!

});
}
}

/**
* Returned when we try to create an alias but the API returns an error telling
* that the given alias is not valid.
@@ -46,6 +46,9 @@ export default async function patchDeploymentScale(
if (error.code === 'not_supported_min_scale_slots') {
return new Errors.NotSupportedMinScaleSlots(url);
}
if (error.code === 'deployment_type_unsupported') {
return new Errors.DeploymentTypeUnsupported();
}

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