Versions des environnements
>>>Hi,
>>>
>>>I am working on creating a good error-catching approach for the following scenario:
>>>
>>>The UI of the ASP.NET calls a method of a class that is supposed to return a DataSet. Let's call this class and method DataAccess.GetDataSet(). Inside the method GetDataSet I have Try Catch. If there is a problem I can get the error description from the exception caught with Catch. But how do I notify the calling routine that there was problem creating the dataset? The GetDataSet is supposed to return dataset and not a string.
>>>
>>>TIA for any suggestions.
>>
>>IMO, unless you have a very good reason not to, I'd just rethrow the exception. Any other solution will depend on the calling routine knowing that it must check for success/failure and there is not guarantee that that will happen.
>>
>>Otherwise you could use John's suggestion. Or have the method return a bool and use a ref or out parameter for the dataset. Or use a tuple. Or.....
>
>I just re-read your message and see that you used Out parameter for the dataset. This was a problem I was having discussed in another thread. I had to use Out parameter when passing the dataset but didn't know if it could be done without the Out parameter. I suppose you confirmed that the Out parameter is the must for passing data set by reference.
>Please correct me if I am wrong.
You can use 'out' or 'ref'. The difference is that is you use ref then the parameter item must be instantiated before the call ; if you use 'out' it need only be declared.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement