From 14eafb636a5ab027ac15e3dad1fc4ebbcd388f37 Mon Sep 17 00:00:00 2001 From: silviroa Date: Wed, 3 Sep 2025 15:11:56 -0300 Subject: [PATCH] FIX(Services): cambia captura de error del fetch --- services/src/http-client.ts | 43 ++++++------------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/services/src/http-client.ts b/services/src/http-client.ts index bd1aa77..7acb2eb 100644 --- a/services/src/http-client.ts +++ b/services/src/http-client.ts @@ -28,41 +28,12 @@ export async function HTTPClient(etl: ETL, config: any, datos: any) { return await res.text(); } } else { - throw new Error(await res.text()); + const body = await res.text().catch(() => ''); + const error = new Error(`HTTP ${res.status} ${res.statusText} - ${body}`); + // Agregamos info extra al objeto de error + (error as any).status = res.status; + (error as any).statusText = res.statusText; + (error as any).body = body; + throw error; } } - - -// const servicioEjemplo = { -// name: 'sisa-get-ciudadano', -// type: 'http-client', -// configuration: { -// url: '', -// method: 'POST', -// body: form, -// headers: {}, -// params: {}, -// json : true -// } -// }; - - -// HTTPClient( -// { -// url: { -// $apply: { -// fn: 'concat', -// args: ['$.dominio', '/api/core/tm/paises'] -// } -// }, -// method: 'GET', -// params: { -// nombre: '$.nombre' -// }, -// json: false -// }, -// { -// nombre: 'arg', -// dominio: 'https://test.andes.gob.ar' -// } -// ).then(console.log);