fix: Prisma 에러 처리 코드를 PostgreSQL 에러 코드로 변경
변경사항:
1. errorHandler.ts:
- Prisma 에러 처리 제거
- PostgreSQL 에러 코드 기반 처리 추가:
* 23505: unique_violation (중복 데이터)
* 23503: foreign_key_violation (참조 무결성)
* 23502: not_null_violation (필수값 누락)
2. dataflowDiagramController.ts:
- P2002 (Prisma) → 23505 (PostgreSQL)
- unique constraint 에러 처리 개선
3. commonCodeController.ts:
- Prisma 에러 처리 주석 수정
- PostgreSQL 23505 에러 코드 추가
최종 확인:
- ✅ prisma. 호출: 0개
- ✅ PrismaClient import: 0개
- ✅ Prisma 파일: 0개
- ✅ package.json Prisma 의존성: 0개
- ✅ TypeScript 컴파일 에러: 0개
- ✅ 모든 Prisma 관련 코드 제거 완료
This commit is contained in:
@@ -25,16 +25,25 @@ export const errorHandler = (
|
||||
let error = { ...err };
|
||||
error.message = err.message;
|
||||
|
||||
// Prisma 에러 처리
|
||||
if (err.name === "PrismaClientKnownRequestError") {
|
||||
const message = "데이터베이스 요청 오류가 발생했습니다.";
|
||||
error = new AppError(message, 400);
|
||||
}
|
||||
|
||||
// Prisma 유효성 검증 에러
|
||||
if (err.name === "PrismaClientValidationError") {
|
||||
const message = "입력 데이터가 유효하지 않습니다.";
|
||||
error = new AppError(message, 400);
|
||||
// PostgreSQL 에러 처리 (pg 라이브러리)
|
||||
if ((err as any).code) {
|
||||
const pgError = err as any;
|
||||
// PostgreSQL 에러 코드 참조: https://www.postgresql.org/docs/current/errcodes-appendix.html
|
||||
if (pgError.code === "23505") {
|
||||
// unique_violation
|
||||
error = new AppError("중복된 데이터가 존재합니다.", 400);
|
||||
} else if (pgError.code === "23503") {
|
||||
// foreign_key_violation
|
||||
error = new AppError("참조 무결성 제약 조건 위반입니다.", 400);
|
||||
} else if (pgError.code === "23502") {
|
||||
// not_null_violation
|
||||
error = new AppError("필수 입력값이 누락되었습니다.", 400);
|
||||
} else if (pgError.code.startsWith("23")) {
|
||||
// 기타 무결성 제약 조건 위반
|
||||
error = new AppError("데이터 무결성 제약 조건 위반입니다.", 400);
|
||||
} else {
|
||||
error = new AppError("데이터베이스 오류가 발생했습니다.", 500);
|
||||
}
|
||||
}
|
||||
|
||||
// JWT 에러 처리
|
||||
|
||||
Reference in New Issue
Block a user