In a library I am writing, I have some methods which would only be executed very rarely and on the fly. As I am modelling a vehicle, one of the (Exceptional) methods is a cracked engine, which would be very rare. Should I throw an exception in this method? This will stop a vehicle from being usable.
I read the .NET Design Framework Guidelines book and it states that an exception should only occur when a method cannot complete execution. The actual engine cracked method will always complete, but if one of my methods, such as start engine (this method will store the amount of engine starts as a means of accruing stress to the engine), is called and results in a call to cracked engine, where (if anywhere) should I throw an exception?
Think an exception should be thrown to highlight code or runtime issues. This is actually normal system logic (in this sense that a cracked engine is a model state, not a code problem), so shouldn’t throw.
Instead, there should be some feedback mechanism that makes sense in the context of the system you’re modelling.