Skip to content
Permalink
Browse files

Fix the handling of user errors (#1959)

* fix unexpected `size_limit_exceeded`

* fix unexpected `deployment_type_unsupported`

* fix unexpected `JSONError`

* check if err.sizeLimit exists
  • Loading branch information...
juliangruber authored and leo committed Mar 15, 2019
1 parent 402c4e7 commit 803b1ae91b672b269dc87a248c6dd80320418f3c
@@ -460,6 +460,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;
}
@@ -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;
}
@@ -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
@@ -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`
});
}
}

/**
* 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;
}

0 comments on commit 803b1ae

Please sign in to comment.
You can’t perform that action at this time.