Do codeContract only throw exceptions?
-
quarta-feira, 2 de maio de 2012 05:54
Hi,
Just learning about codecontracts. It seems very neat and good if you want to throw exceptions.
What about if you dont want to throw exceptions and return a resultList if you like of all the errors?
Can this be done with codecontract?
thanks
Thanks for your help
Todas as Respostas
-
quarta-feira, 2 de maio de 2012 07:17
Hi devBrix,
you can subscribe the Contracts.ContractFailed static event. You can process a contract failure on your own in the handler and then call e.SetHandled().
Hth.
-
quarta-feira, 2 de maio de 2012 08:04
Hi
Thanks for your reply
What I want to do is
Use CodeContracts
When a contract fails I want to add the error to my ErrorList and return it.
Can I add to my own list in the eventHandler then?thanks
Thanks for your help
-
quarta-feira, 2 de maio de 2012 08:15
In the event handler you can log the failure to some static list. After the code whose contract failures are to be monitored finishes, you can process the list - for example write it to a file etc.
What do you mean by "returning it"? Neither the contract nor the event handler can return a value.
- Marcado como Resposta devBrix quarta-feira, 2 de maio de 2012 10:42

