Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

throwing an exception in a windows service

Does throwing an exception in a windows service crash the service?

i.e. it will have to be restarted manually

Note: I am throwing the exception from within the catch clause.

like image 227
Blankman Avatar asked Jan 02 '09 19:01

Blankman


People also ask

Should a service throw exception?

The rule of thumb I tend to follow is to throw an exception as soon as I can't continue or recover the desired code execution path, then allow that exception to propagate back up the stack to a place that understands how to handle that exception. Don't catch an exception if all you're going to do is re-throw.

Why would you want to throw an exception?

Exceptions should be thrown when the contract between a method and its caller cannot be fulfilled.

Can you throw an exception at any point?

Any code can throw an exception: your code, code from a package written by someone else such as the packages that come with the Java platform, or the Java runtime environment. Regardless of what throws the exception, it's always thrown with the throw statement.

When should you raise exceptions?

Exceptions should be used for exceptional situations outside of the normal logic of a program. In the example program an out of range value is likely to be fairly common and should be dealt with using normal if-else type logic.


1 Answers

Not strictly so -- it'd only cause problems if the exception is unhandled.

like image 167
Rowland Shaw Avatar answered Sep 23 '22 17:09

Rowland Shaw