Formateo
This commit is contained in:
parent
d60b8276f6
commit
5c51093b1d
@ -1,9 +1,7 @@
|
|||||||
import { loggerSingleton } from "@repo/rdx-logger";
|
|
||||||
import { Result } from "@repo/rdx-utils";
|
import { Result } from "@repo/rdx-utils";
|
||||||
|
import { logger } from "../../helpers";
|
||||||
import { ITransactionManager } from "./transaction-manager.interface";
|
import { ITransactionManager } from "./transaction-manager.interface";
|
||||||
|
|
||||||
const logger = loggerSingleton();
|
|
||||||
|
|
||||||
export abstract class TransactionManager implements ITransactionManager {
|
export abstract class TransactionManager implements ITransactionManager {
|
||||||
protected _transaction: unknown | null = null;
|
protected _transaction: unknown | null = null;
|
||||||
protected _isCompleted = false;
|
protected _isCompleted = false;
|
||||||
|
|||||||
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
DomainValidationError,
|
DomainValidationError,
|
||||||
ValidationErrorCollection,
|
|
||||||
isDomainValidationError,
|
isDomainValidationError,
|
||||||
isValidationErrorCollection,
|
isValidationErrorCollection,
|
||||||
|
ValidationErrorCollection,
|
||||||
} from "@repo/rdx-ddd";
|
} from "@repo/rdx-ddd";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { NextFunction, Request, Response } from "express";
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import { logger } from "../../../helpers";
|
||||||
import { ApiErrorContext, ApiErrorMapper, toProblemJson } from "../api-error-mapper";
|
import { ApiErrorContext, ApiErrorMapper, toProblemJson } from "../api-error-mapper";
|
||||||
|
|
||||||
// ✅ Construye tu mapper una vez (composition root del adaptador HTTP)
|
// ✅ Construye tu mapper una vez (composition root del adaptador HTTP)
|
||||||
@ -10,7 +11,7 @@ export const globalErrorHandler = async (
|
|||||||
res: Response,
|
res: Response,
|
||||||
next: NextFunction
|
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
|
// Si ya se envió una respuesta, delegamos al siguiente error handler
|
||||||
if (res.headersSent) {
|
if (res.headersSent) {
|
||||||
@ -26,7 +27,9 @@ export const globalErrorHandler = async (
|
|||||||
const body = toProblemJson(apiError, ctx);
|
const body = toProblemJson(apiError, ctx);
|
||||||
|
|
||||||
// 👇 Log interno con cause/traza (no lo exponemos al cliente)
|
// 👇 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);
|
res.status(apiError.status).json(body);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user