Rowupdating error handling

However, simply stopping the script is not always the right way to go.

Let's take a look at alternative PHP functions for handling errors. We simply create a special function that can be called when an error occurs in PHP.

The default error handler for PHP is the built in error handler.

We are going to make the function above the default error handler for the duration of the script.

You can reach Trevor on Twitter ( or follow him on his blog, Trevor Sullivan's Tech Room, Minding the gap between administration and development. If you have any questions, send email to me at [email protected], or post your questions on the Official Scripting Guys Forum.

There are three types of errors in programming: (a) Syntax Errors, (b) Runtime Errors, and (c) Logical Errors.

However, in this example we are going to use our custom error handler for all errors: function you can send error logs to a specified file or a remote destination.

When these errors occur, they are considered “terminating errors.”As an example, if you want to stop the execution of your Windows Power Shell script when an error occurs during a call to Stop-Process, you can simply add the -Error Action parameter and use the value Stop: Stop-Process -Name invalidprocess -Error Action Stop; If you want to suppress the errors from being displayed, you can use the value Silently Continue, for example: Stop-Process -Name invalidprocess -Error Action Silently Continue; You can also combine the Error Action and Error Variable parameters, such as in this example: Stop-Process –Name invalidprocess -Error Action Silently Continue -Error Variable Process Error; If ($Process Error) We have explored the use of two Windows Power Shell common parameters, Error Action and Error Variable.

I hope that this post has enlightened you about the use of these variables and how to use them to direct the execution flow of your scripts.

When Windows Power Shell 2.0 came out, a new concept was introduced, called Advanced Functions.

This concept allows you to develop commands that have the same feel as compiled cmdlets, while writing them in Windows Power Shell script syntax.

Leave a Reply