Log del JSON enviado al Service Layer cuando SAP rechaza, para todos los documentos. Versión 2.1.5.0

Se mueve de CreditNotesRepository a ConnectionServiceLayer (PostAsync,
PatchAsyncSBA, PatchNoContentAsync) con un hook asignado en Startup.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GeorgeandClaude Sonnet 5.5 committed 2026-10-14 17:06:07 -05:00
1 parent 1ce0da7735
commit e5ea57b673
5 files changed
+39 -24

No files matched your search

@@ -19,6 +19,16 @@ namespace Net.Connection.ServiceLayer
public static bool ServicioActivo = false;
public static string SLSession;
// Se invoca solo cuando SAP rechaza un envio: (ruta del recurso, JSON enviado, respuesta de SAP).
// Lo asigna Startup (esta capa no conoce HANA).
public static Action<string, object, string> ErrorLogger;
private static void LogErrorEnvio(string query, object jsonEnviado, string respuesta)
{
try { ErrorLogger?.Invoke(query, jsonEnviado, respuesta); }
catch { /* el log nunca debe romper el flujo principal */ }
}
private readonly string _url;
private readonly string _company;
private readonly string _user;
@@ -464,6 +474,7 @@ namespace Net.Connection.ServiceLayer
var estado = (int)response_.StatusCode;
responseBody.CodigoHttp = estado.ToString();
responseBody.Mensaje = "Services Unauthorized : " + _responseLoginServiceLayer.error.message.ToString();
LogErrorEnvio(Query, obj, responseBody.Mensaje);
return responseBody;
}
@@ -493,6 +504,7 @@ namespace Net.Connection.ServiceLayer
var estado = (int)response_.StatusCode;
responseBody.CodigoHttp = estado.ToString();
responseBody.Mensaje = "Error Services : " + _responseLoginServiceLayer.error.message.ToString();
LogErrorEnvio(Query, obj, responseBody.Mensaje);
return responseBody;
}
@@ -1072,6 +1084,7 @@ namespace Net.Connection.ServiceLayer
var estado = (int)response_.StatusCode;
//responseBody.CodigoHttp = estado.ToString();
responseBody.Mensaje = "Services Unauthorized : " + _responseLoginServiceLayer.error.message.ToString();
LogErrorEnvio(Query, obj, responseBody.Mensaje);
return responseBody;
}
@@ -1096,6 +1109,7 @@ namespace Net.Connection.ServiceLayer
var estado = (int)response_.StatusCode;
//responseBody.CodigoHttp = estado.ToString();
responseBody.Mensaje = "Error Services : " + _responseLoginServiceLayer.error.message.ToString();
LogErrorEnvio(Query, obj, responseBody.Mensaje);
return responseBody;
}
@@ -1163,7 +1177,9 @@ namespace Net.Connection.ServiceLayer
return; // exito real - sin body que parsear
}
throw new Exception(ExtraerMensajeErrorSap(responseText_));
var mensajeError = ExtraerMensajeErrorSap(responseText_);
LogErrorEnvio(Query, obj, mensajeError);
throw new Exception(mensajeError);
}
}