Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/11/2013, 12:00
th3r0rn
 
Fecha de Ingreso: noviembre-2007
Mensajes: 504
Antigüedad: 16 años, 5 meses
Puntos: 2
Como cachar una exepcion y retornar el error si mi funcion retorna un LIST

Hola, Tengo un web services con varias funciones, varias de ellas retornan un string, entonces es facil poner en el catch lo siguiente:
Código:
  catch (Exception ex)
        {
            P_RESULT = ex.ToString();
            return P_RESULT;
           // return null;
        }
Esto es muy facil si mi funcion retorna un string, pero si tenemos una que retorna un LIST como puedo retornar el mensaje de error? ejemplo:

Código C#:
Ver original
  1. [WebMethod]
  2.     public List<Datos> ZPKG_GETINVENTARIO001(string centro, string P_FECHA)
  3.     {
  4.  
  5.  
  6.        ECCDestinationConfig onk1 = new ECCDestinationConfig();
  7.         onk1.compruebaconection();
  8.  
  9.         prd = RfcDestinationManager.GetDestination("QAS");
  10.  
  11.         try
  12.         {
  13.             RfcDestinationManager.RegisterDestinationConfiguration(new ECCDestinationConfig());
  14.  
  15.         }
  16.  
  17.         catch
  18.         {
  19.  
  20.         }
  21.                                
  22.  
  23.         try
  24.         {
  25.  
  26.  
  27.             Datos objBankList = new Datos();
  28.             List<Datos> objBank = new List<Datos>();
  29.  
  30.             RfcRepository repo = prd.Repository;
  31.  
  32.             IRfcFunction IRfcGetInventario = repo.CreateFunction("ZPKG_GETINVENTARIO001");
  33.             IRfcGetInventario.SetValue("P_WERKS", centro);
  34.             IRfcGetInventario.SetValue("P_FECHA", P_FECHA);
  35.  
  36.             IRfcGetInventario.Invoke(prd);
  37.  
  38.            
  39.  
  40.             List<IRfcStructure> irc = new List<IRfcStructure>();
  41.  
  42.             IRfcTable detail = IRfcGetInventario["T_INVENTARIO"].GetTable();
  43.             List<string> cnt = new List<string>();
  44.  
  45.  
  46.             foreach (IRfcStructure ir in detail)
  47.             {
  48.  
  49.                 objBank.Add(new MyBackendConfig().Insert(ir));
  50.  
  51.             }
  52.             return objBank;
  53.         }
  54.  
  55.         catch (Exception ex)
  56.         {
  57.  
  58.            
  59.             return null;
  60.         }
  61.  
  62.     }
Aqui nose como mostrar el mensaje de error ya que no lo puedo asignar a una variable de texto de retorno ya que mi funcion retorna LIST y no string.
Alguien me puede orientar?
Saludos,
Luis