You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1021 B

// Packages
const ms = require("ms");
const chalk = require("chalk");
const error = require("./utils/output/error");
function handleError(err) {
if (err.status === 403) {
error(
"Authentication error. Run `now -L` or `now --login` to log-in again."
);
} else if (err.status === 429) {
if (err.retryAfter === "never") {
error(err.message);
} else if (err.retryAfter === null) {
error("Rate limit exceeded error. Please try later.");
} else {
error(
"Rate limit exceeded error. Try again in " +
ms(err.retryAfter * 1000, { long: true }) +
", or upgrade your account by runnung " +
`${chalk.gray("`")}${chalk.cyan("now upgrade")}${chalk.gray("`")}`
);
}
} else if (err.userError) {
error(err.message);
} else if (err.status === 500) {
error("Unexpected server error. Please retry.");
} else {
error(`Unexpected error. Please try later. (${err.message})`);
}
}
module.exports = {
handleError,
error
};