U N D E R S TA N D I N G S T R U C T U R E D E X C E P T I O N H A N D L I N G
return string.Format("Car Error Message: {0}", messageDetails);
}
}
}
Here, the CarIsDeadException type maintains a private data member (messageDetails) that
represents data regarding the current exception, which can be set using a custom constructor.
Throwing this error from the Accelerate() method is straightforward. Simply allocate, configure,
and throw a CarIsDeadException type rather than a System.Exception (notice that in this case, we
no longer need to fill the data collection manually):
Do'stlaringiz bilan baham: