Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Exception handling
Message
De
27/05/2017 04:19:24
 
 
Information générale
Forum:
C#
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01651425
Message ID:
01651554
Vues:
52
This message has been marked as a message which has helped to the initial question of the thread.
>>>Hi Viv,
>>>
>>>My message perhaps was not very clear. I am asking about the line throw ex - is it possible to enhance this line to include inner exception directly?
>>
>>As above ex DOES include the inner exception (if there is one). If you want to discard the top level exception and simply pass the inner exception then use:
throw ex.InnerException
>>
>>
>>>
>>>That error is later shown on the screen and it says exactly 'error such and such see inner exceptions for details'. This message is not very helpful to the user. I can try to see where in the interface code we're showing that exception and may be add some code there but I've been wondering if it somehow possible when I throw exception enhance its message to include the text of the inner exception directly into the message.
>
>
>No, I want to pass the original exception but the message should include both original exception + Inner exception if it exists in one message. Not the current standard text saying that you have to look at the inner exception.

Exception properties are read only so the best you can do is something like:
throw new Exception(ex.Message + ex.InnerException.Message, ex);
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform