{"id":41787,"library":"prisma-error-formatter","title":"prisma-error-formatter","description":"A TypeScript library v5.0.0 for formatting Prisma Client errors into user-friendly, consistent messages. Supports known request errors (unique constraint, foreign key, not found), validation errors, initialization errors, and panic errors. Allows custom formatting via callback. Requires @nestjs/common ^10.0.0, @nestjs/core ^10.0.0, @prisma/client >=4.0.0. Actively maintained on GitHub with MIT license. Differentiated by structured output with path/message and full NestJS integration.","status":"active","version":"5.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/nurulislamrimon/nestjs-exception-handler","tags":["javascript","nestjs","exception","filter","error","handler","prisma","error-handler","exception-filter","typescript"],"install":[{"cmd":"npm install prisma-error-formatter","lang":"bash","label":"npm"},{"cmd":"yarn add prisma-error-formatter","lang":"bash","label":"yarn"},{"cmd":"pnpm add prisma-error-formatter","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for NestJS integration","package":"@nestjs/common","optional":true},{"reason":"Peer dependency for NestJS integration","package":"@nestjs/core","optional":true},{"reason":"Peer dependency for Prisma error types","package":"@prisma/client","optional":false}],"imports":[{"note":"ESM-only; CJS require will not work. Named export.","wrong":"const PrismaExceptionFormatter = require('prisma-error-formatter')","symbol":"PrismaExceptionFormatter","correct":"import { PrismaExceptionFormatter } from 'prisma-error-formatter'"},{"note":"Type exported from main package, not a separate path.","wrong":"import { ErrorMessage } from 'prisma-error-formatter/types'","symbol":"ErrorMessage","correct":"import { ErrorMessage } from 'prisma-error-formatter'"},{"note":"Use type import to avoid runtime side effects.","wrong":"import { FormatFunction } from 'prisma-error-formatter'","symbol":"FormatFunction","correct":"import type { FormatFunction } from 'prisma-error-formatter'"}],"quickstart":{"code":"import { PrismaClient } from '@prisma/client';\nimport { PrismaExceptionFormatter } from 'prisma-error-formatter';\n\nconst prisma = new PrismaClient();\nconst formatter = new PrismaExceptionFormatter();\n\nasync function run() {\n  try {\n    await prisma.user.create({ data: { email: 'test@example.com' } });\n  } catch (error) {\n    const errors = formatter.formatError(error);\n    console.log(errors);\n    // Example: [{ path: 'email', message: 'A record with this email already exists.' }]\n  } finally {\n    await prisma.$disconnect();\n  }\n}\n\nrun();","lang":"typescript","description":"Creates a PrismaExceptionFormatter and uses it to catch and format a Prisma error in a create operation."},"warnings":[{"fix":"Update import from older versions. Import { PrismaExceptionFormatter } from 'prisma-error-formatter'.","message":"Version 5.0.0 changed the API: former single export is now PrismaExceptionFormatter class.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Replace calls to deprecated methods with formatter.formatError(error).","message":"Methods formatPrismaError, formatQueryError, formatInitializationError are deprecated in v5. Use formatError instead.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Use new PrismaExceptionFormatter() instead of PrismaExceptionFormatter().","message":"PrismaExceptionFormatter is a class, not a function. Must call new PrismaExceptionFormatter().","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Use ESM imports (import) or dynamic import() in CJS.","message":"The package is ESM-only; CommonJS require() throws a runtime error.","severity":"gotcha","affected_versions":">=5.0.0"},{"fix":"Install @nestjs/common and @nestjs/core if using with NestJS, otherwise ignore.","message":"Peer dependencies @nestjs/common and @nestjs/core are required for NestJS exception filter use, but not for standalone use.","severity":"gotcha","affected_versions":">=5.0.0"}],"env_vars":null,"search_vec":"'10.0.0':44,46 '4.0.0':48 'activ':49 'allow':37 'callback':41 'client':12 'consist':18 'constraint':25 'custom':38 'differenti':56 'error':3,13,23,31,33,36,70,74 'error-handl':73 'except':68,77 'exception-filt':76 'filter':69,78 'foreign':26 'format':10,39 'formatt':4 'found':29 'friend':17 'full':63 'github':52 'handler':71,75 'initi':32 'integr':65 'javascript':66 'key':27 'known':21 'librari':7 'licens':55 'maintain':50 'messag':19 'mit':54 'nestj':64,67 'nestjs/common':43 'nestjs/core':45 'output':59 'panic':35 'path/message':61 'prisma':2,11,72 'prisma-error-formatt':1 'prisma/client':47 'request':22 'requir':42 'structur':58 'support':20 'typescript':6,79 'uniqu':24 'user':16 'user-friend':15 'v5.0.0':8 'valid':30 'via':40","created_at":"2026-06-04T18:54:06.565614+00:00","updated_at":"2026-06-04T18:54:06.565614+00:00","problems":[{"fix":"Use new PrismaExceptionFormatter() and ensure named import: import { PrismaExceptionFormatter } from 'prisma-error-formatter'.","cause":"Trying to call PrismaExceptionFormatter() without new, or importing as default import in older version.","error":"TypeError: PrismaExceptionFormatter is not a constructor"},{"fix":"Run npm install prisma-error-formatter. In tsconfig.json, set moduleResolution to 'node16' or 'nodenext'.","cause":"Package not installed or TypeScript not configured for ESM resolution.","error":"Cannot find module 'prisma-error-formatter' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/nurulislamrimon/nestjs-exception-handler#readme","github":"https://github.com/nurulislamrimon/nestjs-exception-handler","docs":null,"changelog":null,"pypi":null,"npm":"prisma-error-formatter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}