Catching Exceptions
Because the Accelerate() method now throws an exception, the caller needs to be ready to handle
the exception should it occur. When you are invoking a method that may throw an exception, you
make use of a try/catch block. Once you have caught the exception object, you are able to invoke
the members of the System.Exception type to extract the details of the problem. What you do with
this data is largely up to you. You may wish to log this information to a report file, write the data to
the Windows event log, e-mail a system administrator, or display the problem to the end user. Here,
you will simply dump the contents to the console window:
Do'stlaringiz bilan baham: |