Handling Errors in a Project

Looking for an example project to get you started?
1 post Page 1 of 1


Post by Support_Sai » Fri May 01, 2009 8:17 am
When creating a project, one can define the action to take when there is an error in a Task, Module or the Project. For example, you want to create a project to FTP a file to a remote server, and if the project fails for any reason, you want to send an email to one or more users. The example project below demonstrates how this can be achieved:
Code: Select all
<project name="Error Handling Example" mainModule="Main" version="1.0" onError="call:Send Error Notification">

	<module name="Main">
		<ftp resourceId="My FTP Server">
			<put sourceFile="/myfile.txt" destinationDir="/targetdir" />

	<module name="Send Error Notification">
		<sendEmail resourceId="My Mail Server" toList="user1@company.com, user2@company.com">
			<from address="GoAnywhere@company.com" />
				<![CDATA[The following error occurred when running the project, ${system.project.name}: 


			<message>The following error occurred when running the project, ${system.project.name}: 



In the above project, we defined On Error at the project level to call a module named Send Error Notification. This can be setup under the Advanced tab of the project. Then in the Send Error Notification module, we have a sendEmail task for sending an email. After the sendEmail task, we also have a raiseError task to raise an error with a custom message.

Since we caught the error with our Send Error Notification module the job will always be marked as successful unless we use the raiseError task.

The error handling can also be customized at a specific module level, or at a specific task level, by defining the On Error attribute on the module or task. This option can be found under the Advanced tab of every module and task.

If you are using GoAnywhere's scheduler to run a project, the Scheduler has built-in email notification when the project completes normally or with an error. We recommend that you use this option if all you want to do is get email notifications upon errors.
1 post Page 1 of 1