Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
CliError -> UserError
Roman Pominovc43f925d3113
diff --git a/packages/prisma-client/migrations-cli/cli-error.ts b/packages/prisma-client/migrations-cli/cli-error.tsdeleted file mode 100644index c5f4d3a163..0000000000--- a/packages/prisma-client/migrations-cli/cli-error.ts+++ /dev/null@@ -1,6 +0,0 @@-// A special error that when thrown signals-// to the CLI that it doesn't need to print the stacktrace.-//-// This should be used for the errors caused by user's input or actions-// as opposed to errors caused by bugs in the code.-export class CliError extends Error {}diff --git a/packages/prisma-client/migrations-cli/cli.ts b/packages/prisma-client/migrations-cli/cli.tsindex cf97b6ded7..1e98907409 100755--- a/packages/prisma-client/migrations-cli/cli.ts+++ b/packages/prisma-client/migrations-cli/cli.ts@@ -4,7 +4,7 @@ import * as dotenv from "dotenv";import * as commands from "./commands";import * as logger from "./logger";import args from "./args";-import { CliError } from "./cli-error";+import { UserError } from "./cli-error";const USAGE = `Usage: migrations <command> [--dev]@@ -36,7 +36,7 @@ const main = async () => {if (command === "create-schema") {const name = args._[1];if (name === undefined) {- throw new CliError(+ throw new UserError("Missing name for migration.\nUsage: migrations create-schema <name>");}@@ -47,7 +47,7 @@ const main = async () => {if (command === "create-data") {const name = args._[1];if (name === undefined) {- throw new CliError(+ throw new UserError("Missing name for migration.\nUsage: migrations create-data <name>");}@@ -72,14 +72,14 @@ const main = async () => {type === undefined ||(type !== "applied" && type !== "rolled-back")) {- throw new CliError(+ throw new UserError("Missing type of resolve.\nUsage: migrations resolve <applied|rolled-back> <migration-name>");}const name = args._[2];if (name === undefined) {- throw new CliError(+ throw new UserError("Missing name of migration.\nUsage: migrations resolve <applied|rolled-back> <migration-name>");}@@ -93,9 +93,9 @@ const main = async () => {return;}- throw new CliError(`Unknown command: ${command}`);+ throw new UserError(`Unknown command: ${command}`);} catch (error) {- if (error instanceof CliError) {+ if (error instanceof UserError) {logger.error(error.message);logger.error("");process.exit(1);diff --git a/packages/prisma-client/migrations-cli/commands.ts b/packages/prisma-client/migrations-cli/commands.tsindex 02a89a3ae7..55bcf48028 100644--- a/packages/prisma-client/migrations-cli/commands.ts+++ b/packages/prisma-client/migrations-cli/commands.ts@@ -6,7 +6,7 @@ import * as prismaMigrations from "./prisma-migrations";import { umzug } from "./umzug";import * as logger from "./logger";import args from "./args";-import { CliError } from "./cli-error";+import { UserError } from "./errors";const templateFilePath = path.join(prismaMigrations.migrationsDir,@@ -106,7 +106,7 @@ const ensureNoFailed = (status: Status) => {(migration) => migration.state === "failed");if (failed.length > 0) {- throw new CliError(+ throw new UserError(`There are failed migrations:\n${failed.map((item) => {let text = ` - ${item.migration.migration_name}`;@@ -125,7 +125,7 @@ const ensureNoFailed = (status: Status) => {const ensureNoPending = (status: Status) => {if (status.pending.length > 0) {- throw new CliError(+ throw new UserError(`There are pending migrations:\n${status.pending.map((migration) => ` - ${migration.name}`).join(@@ -140,7 +140,7 @@ const ensureLastPending = async (migrationsName: string) => {const last = pending[pending.length - 1];if (last === undefined || last.name !== migrationsName) {- throw new CliError(+ throw new UserError("The migrations you've created did not appear as the last pending migration. This isn't supposed to happen. Please investigate / report this issue.");}@@ -247,7 +247,7 @@ const up = async () => {try {await locker.getLock();} catch (e) {- throw new CliError(+ throw new UserError(`Could not acquire lock!This means that another process is already running migrations.If you're sure no other process is running, please delete the lockfile:@@ -344,7 +344,7 @@ export const resolve = async ({({ migration }) => migration.migration_name === migrationName) === false) {- throw new CliError(+ throw new UserError(`Migration ${migrationName} is not failed. You can resolve only a failed migration.`);}@@ -377,7 +377,7 @@ export const reset = async () => {await getStatus();if (args.dev === false) {- throw new CliError(+ throw new UserError("This command is only available in dev mode. Try again with --dev.");}diff --git a/packages/prisma-client/migrations-cli/errors.ts b/packages/prisma-client/migrations-cli/errors.tsnew file mode 100644index 0000000000..dee07c6527--- /dev/null+++ b/packages/prisma-client/migrations-cli/errors.ts@@ -0,0 +1,3 @@+// Throw this error to indicate to CLI that this a error caused by user actions+// as opposed to a bug, so it won't print the stacktrace+export class UserError extends Error {}diff --git a/packages/prisma-client/migrations-cli/prisma-migrations.ts b/packages/prisma-client/migrations-cli/prisma-migrations.tsindex 8ceba95120..bd1ab06410 100644--- a/packages/prisma-client/migrations-cli/prisma-migrations.ts+++ b/packages/prisma-client/migrations-cli/prisma-migrations.ts@@ -7,7 +7,7 @@ import path from "node:path";import fs from "node:fs";import { createHash } from "node:crypto";import { prisma } from "../src";-import { CliError } from "./cli-error";+import { UserError } from "./errors";export const prismaDir = path.resolve(__dirname, "..", "prisma");export const schemaFilePath = path.join(prismaDir, "schema.prisma");@@ -291,7 +291,7 @@ export const generateMigrationClient = (migrationName: string) => {if (fs.existsSync(schemaPath) === false) {const tsFilePath = getMigrationFilePath(migrationName, "ts");if (fs.existsSync(tsFilePath)) {- throw new CliError(+ throw new UserError(`Can't generate client for ${migrationName} because ${migrationName}/schema.prisma is missing`);}diff --git a/packages/prisma-client/migrations-cli/umzug.ts b/packages/prisma-client/migrations-cli/umzug.tsindex 0d0f4666db..5345ed0f7c 100755--- a/packages/prisma-client/migrations-cli/umzug.ts+++ b/packages/prisma-client/migrations-cli/umzug.ts@@ -2,7 +2,7 @@ import { Umzug } from "umzug";import fs from "node:fs";import * as prismaMigrations from "./prisma-migrations";import * as logger from "./logger";-import { CliError } from "./cli-error";+import { UserError } from "./errors";export const umzug = new Umzug({migrations: {@@ -40,7 +40,7 @@ export const umzug = new Umzug({const migration = require(tsFilePath);if (typeof migration.default !== "function") {- throw new CliError(+ throw new UserError(`Migration file's ${tsFilePath} default export must be a function`);}@@ -51,7 +51,7 @@ export const umzug = new Umzug({};}- throw new CliError(+ throw new UserError(`Couldn't find a migration.ts or migration.sql file in migrations/${params.name}`);},