A more generic implementation will be
C#
public class ReturnMessage
{
//indicates success or failure of the function
public bool IsSuccess { get; set; }
//messages(if any)
public string Message { get; set; }
//data (if any)
public T Data { get; set; }
}
VB.NET
Public Class ReturnMessage(Of T)
'indicates success or failure of the function
Public Property IsSuccess As Boolean
'messages(if any)
Public Property Message As String
'data (if any)
Public Property Data As T
End Class
By this method one can pass the ex.Message
in the catch block and Data
in the try block