This commit is contained in:
David Arranz 2025-11-06 17:15:17 +01:00
parent d60b8276f6
commit 5c51093b1d
3 changed files with 7 additions and 6 deletions

View File

@ -1,9 +1,7 @@
import { loggerSingleton } from "@repo/rdx-logger";
import { Result } from "@repo/rdx-utils";
import { logger } from "../../helpers";
import { ITransactionManager } from "./transaction-manager.interface";
const logger = loggerSingleton();
export abstract class TransactionManager implements ITransactionManager {
protected _transaction: unknown | null = null;
protected _isCompleted = false;

View File

@ -13,9 +13,9 @@
import {
DomainValidationError,
ValidationErrorCollection,
isDomainValidationError,
isValidationErrorCollection,
ValidationErrorCollection,
} from "@repo/rdx-ddd";
import {

View File

@ -1,4 +1,5 @@
import { NextFunction, Request, Response } from "express";
import { logger } from "../../../helpers";
import { ApiErrorContext, ApiErrorMapper, toProblemJson } from "../api-error-mapper";
// ✅ Construye tu mapper una vez (composition root del adaptador HTTP)
@ -10,7 +11,7 @@ export const globalErrorHandler = async (
res: Response,
next: NextFunction
) => {
console.error(`❌ Global unhandled error: ${error.message}`);
//console.error(`❌ Global unhandled error: ${error.message}`);
// Si ya se envió una respuesta, delegamos al siguiente error handler
if (res.headersSent) {
@ -26,7 +27,9 @@ export const globalErrorHandler = async (
const body = toProblemJson(apiError, ctx);
// 👇 Log interno con cause/traza (no lo exponemos al cliente)
// logger.error({ err, cause: (err as any)?.cause, ...ctx }, `❌ Unhandled API error: ${error.message}`);
logger.error(`❌ Global unhandled API error: ${error.message}`, {
label: "globalErrorHandler",
});
res.status(apiError.status).json(body);
};