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" />
</ftp>
</module>
<module name="Send Error Notification">
<sendEmail resourceId="My Mail Server" toList="[email protected], [email protected]">
<from address="[email protected]" />
<message>
<![CDATA[The following error occurred when running the project, ${system.project.name}:
${system.job.error}]]>
</message>
</sendEmail>
<raiseError>
<message>The following error occurred when running the project, ${system.project.name}:
${system.job.error}</message>
</raiseError>
</module>
</project>
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.
Note:
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.