From b481bd8f532c7735bd7ddcccf8b81298cdb390f8 Mon Sep 17 00:00:00 2001 From: manuel Date: Fri, 26 Jun 2026 08:54:22 +0200 Subject: [PATCH] =?UTF-8?q?'=20=20=2026/06/2027=20=20MANMOG=20=20Version?= =?UTF-8?q?=203.0.6=20=20=20=20=20Se=20a=C3=B1ade=20tsExcepcion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- My Project/AssemblyInfo.vb | 5 +- tsExcepcion.vb | 107 +++++++++++++++++++++++++++++++++++++ tsl5.vbproj | 1 + 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 tsExcepcion.vb diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 93253ec..bcb3190 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -31,11 +31,12 @@ Imports System.Runtime.InteropServices ' mediante el asterisco ('*'), como se muestra a continuación: ' - - + + ' Modificaciones: ' =============== +' 26/06/2027 MANMOG Version 3.0.6 Se añade tsExcepcion ' 03/06/2027 MANMOG Version 3.0.5 Correccion en tsNotificacionesClient ' 14/05/2026 MANMOG Version 3.0.4 Actualización de .nuspec para que incluya dependencias externas \ No newline at end of file diff --git a/tsExcepcion.vb b/tsExcepcion.vb new file mode 100644 index 0000000..2195de0 --- /dev/null +++ b/tsExcepcion.vb @@ -0,0 +1,107 @@ +Imports System +Imports System.Runtime.Serialization +Imports Microsoft.VisualBasic +Imports Microsoft.VisualBasic.CompilerServices + + + + +Public Class tsExcepcion + Inherits ApplicationException + Public Enum ModoBusquedaEnum As Long + EnTodaLaCadena + DesdeExcepcionSiguiente + SoloEnExcepcionActual + End Enum + + Private pCodigo As String + + Private pDatosExtra As String + + Public ReadOnly Property Codigo As String + Get + Return pCodigo + End Get + End Property + + Public ReadOnly Property DatosExtra As String + Get + Return pDatosExtra + End Get + End Property + + Public Sub New(message As String, Optional argCodigo As String = Nothing, Optional argDatosExtra As String = Nothing) + MyBase.New(message) + pCodigo = argCodigo + pDatosExtra = argDatosExtra + End Sub + + Public Sub New(message As String, innerException As Exception, Optional argCodigo As String = Nothing, Optional argDatosExtra As String = Nothing) + MyBase.New(message, innerException) + pCodigo = argCodigo + pDatosExtra = argDatosExtra + End Sub + + Protected Sub New(info As SerializationInfo, context As StreamingContext) + MyBase.New(info, context) + pCodigo = info.GetString("pCodigo") + pDatosExtra = info.GetString("pDatosExtra") + End Sub + + Public Overrides Sub GetObjectData(info As SerializationInfo, context As StreamingContext) + MyBase.GetObjectData(info, context) + info.AddValue("pCodigo", pCodigo) + info.AddValue("pDatosExtra", pDatosExtra) + End Sub + + Public Shared Function Buscar(excepcion As Exception, patronCodigo As String, Optional modoBusqueda As ModoBusquedaEnum = ModoBusquedaEnum.EnTodaLaCadena) As tsExcepcion + Try + If excepcion Is Nothing Then + Throw New tsExcepcion("'excepcion' es Nothing.") + End If + + If Not [Enum].IsDefined(GetType(ModoBusquedaEnum), modoBusqueda) Then + Throw New tsExcepcion("Modo de búsqueda incorrecto: " & Conversions.ToString(modoBusqueda)) + End If + + Dim ex = excepcion + If modoBusqueda = ModoBusquedaEnum.DesdeExcepcionSiguiente Then + ex = ex.InnerException + End If + + Dim num = 1 + Do + If ex Is Nothing Then + Return Nothing + End If + + If TypeOf ex Is tsExcepcion Then + Dim text = CType(ex, tsExcepcion).Codigo + If Equals(text, Nothing) Then + text = "" + End If + + If LikeOperator.LikeString(text, patronCodigo, CompareMethod.Binary) Then + Return CType(ex, tsExcepcion) + End If + End If + + ex = ex.InnerException + If modoBusqueda = ModoBusquedaEnum.SoloEnExcepcionActual Then + Return Nothing + End If + + num = num + 1 + Loop While num <= 1000000 + Throw New tsExcepcion("Bucle cuasi-infinito.") + Catch ex2 As Exception + ProjectData.SetProjectError(ex2) + Dim ex3 = ex2 + Throw New tsExcepcion("Buscando tsExcepcion con código: " & patronCodigo & vbCrLf & ex3.Message, ex3) + End Try + End Function + + Public Shared Function Es(excepcion As Exception, patronCodigo As String, Optional modoBusqueda As ModoBusquedaEnum = ModoBusquedaEnum.EnTodaLaCadena) As Boolean + Return Buscar(excepcion, patronCodigo, modoBusqueda) IsNot Nothing + End Function +End Class diff --git a/tsl5.vbproj b/tsl5.vbproj index bbd4134..5d57f98 100644 --- a/tsl5.vbproj +++ b/tsl5.vbproj @@ -152,6 +152,7 @@ True +