Ari
Ari

Reputation: 1036

Code Contract Errors

is there a way to alter the way the code contracts behave during run time? as in, when a pre or post conidtion fails during run time, the application crashes. Is there a way instead of crashing, have a MessageBox displayed??

Upvotes: 0

Views: 154

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273274

When a contract fails the program does not 'crash' but an Exception is thrown. The Contracts class lets you control what kind of exception.

So you need some form of Exception Handling, and not just for the Contracts.

Having said that, a failing Contract is usually severe enough to terminate the application.

Upvotes: 2

Related Questions