- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
43 lines
1.5 KiB
JavaScript
43 lines
1.5 KiB
JavaScript
import { printDiffOrStringify } from './diff.js';
|
|
import { stringify } from './display.js';
|
|
import { serializeValue } from './serialize.js';
|
|
import '@vitest/pretty-format';
|
|
import 'tinyrainbow';
|
|
import './helpers.js';
|
|
import './constants.js';
|
|
import './chunk-_commonjsHelpers.js';
|
|
|
|
function processError(_err, diffOptions, seen = new WeakSet()) {
|
|
if (!_err || typeof _err !== "object") {
|
|
return { message: String(_err) };
|
|
}
|
|
const err = _err;
|
|
if (err.showDiff || err.showDiff === undefined && err.expected !== undefined && err.actual !== undefined) {
|
|
err.diff = printDiffOrStringify(err.actual, err.expected, {
|
|
...diffOptions,
|
|
...err.diffOptions
|
|
});
|
|
}
|
|
if ("expected" in err && typeof err.expected !== "string") {
|
|
err.expected = stringify(err.expected, 10);
|
|
}
|
|
if ("actual" in err && typeof err.actual !== "string") {
|
|
err.actual = stringify(err.actual, 10);
|
|
}
|
|
// some Error implementations may not allow rewriting cause
|
|
// in most cases, the assignment will lead to "err.cause = err.cause"
|
|
try {
|
|
if (!seen.has(err) && typeof err.cause === "object") {
|
|
seen.add(err);
|
|
err.cause = processError(err.cause, diffOptions, seen);
|
|
}
|
|
} catch {}
|
|
try {
|
|
return serializeValue(err);
|
|
} catch (e) {
|
|
return serializeValue(new Error(`Failed to fully serialize error: ${e === null || e === void 0 ? void 0 : e.message}\nInner error message: ${err === null || err === void 0 ? void 0 : err.message}`));
|
|
}
|
|
}
|
|
|
|
export { processError, serializeValue as serializeError };
|