Menyelesaikan object user dan init base

This commit is contained in:
Mr. Rayyan
2026-07-30 22:47:18 +07:00
parent 3efac50f39
commit fdbfb34842
128 changed files with 6785 additions and 3156 deletions
+12
View File
@@ -0,0 +1,12 @@
core/exceptions/
Penjelasan:
Berisi global exception filters dan custom exception classes.
Isi yang direkomendasikan:
- http-exception.filter.ts
- domain-exception.ts (custom domain exception base)
Aturan:
- Exception filter mengubah exception menjadi response standar API.
- Gunakan kode error konsisten (error code constant) agar client dapat menangani error.
@@ -0,0 +1,18 @@
import { ExceptionFilter, Catch, ArgumentsHost } from '@nestjs/common';
@Catch()
export class HttpExceptionFilter implements ExceptionFilter {
catch(exception: any, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse();
const status = exception.getStatus ? exception.getStatus() : 500;
response.status(status).json({
success: false,
error: {
code: exception.code || 'INTERNAL_ERROR',
message: exception.message || 'Internal server error',
},
});
}
}