Skip to content

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.

trying to see the error object

Roman Pominov4f80f28837f6
diff --git a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts
index 6b71bb992c..60735d29e6 100644
--- a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts
+++ b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts
@@ -1,4 +1,5 @@
import { PrismaClient } from "./client";
+import { inspect } from "util";
// NOTE ON IMPORTS:
//
@@ -10,23 +11,32 @@ import { PrismaClient } from "./client";
// It's better to copy it to the migration directory.
export default () => {
- const client = new PrismaClient();
- return client.$transaction(async (prisma) => {
- const previousAssets = await prisma.asset.findMany();
- const update = previousAssets.map((asset) => {
- return {
- id: asset.id,
- description: asset.alt,
- meta: JSON.stringify({
- width: Number(asset.width),
- height: Number(asset.height),
- }),
- };
+ try {
+ const client = new PrismaClient();
+
+ return client.$transaction(async (prisma) => {
+ const previousAssets = await prisma.asset.findMany();
+ const update = previousAssets.map((asset) => {
+ return {
+ id: asset.id,
+ description: asset.alt,
+ meta: JSON.stringify({
+ width: Number(asset.width),
+ height: Number(asset.height),
+ }),
+ };
+ });
+ await Promise.all(
+ update.map(({ id, ...data }) =>
+ prisma.asset.update({ where: { id }, data })
+ )
+ );
});
- await Promise.all(
- update.map(({ id, ...data }) =>
- prisma.asset.update({ where: { id }, data })
- )
- );
- });
+ } catch (error) {
+ if (error instanceof Error) {
+ throw error;
+ } else {
+ throw new Error(inspect(error));
+ }
+ }
};