Sub Activity_Create(FirstTime As Boolean)
Try
RecursiveCopy("A")
Catch
Log(LastException.Message)
If LastException.Message.Contains("Copying cancelled") Then
Msgbox("Copy operation cancelled", "Confirmation")
Else
Msgbox(LastException.Message, "Error Occurred")
End If
End Try
End Sub
Sub RecursiveCopy(sTarget As String)
Try
Dim ex As ExceptionEx
If sTarget.Length < 4 Then
RecursiveCopy("B/" & sTarget)
End If
Log("Now processing: " & sTarget)
If sTarget = "B/B/A" Then ' We want to just skip this one, but carry on processing
ex.Initialize("File Skipped")
ex.Throw
Else If sTarget = "B/A" Then ' We want to cancel at this point, but return a meaningful exception
ex.Initialize("Copying cancelled")
ex.Throw
End If
Catch
If ex.IsInitialized Then
If ex.Message = "File Skipped" Then
Log("File copy skipped as requested")
Else If ex.Message = "Copying cancelled" Then
ex.Throw ' Re-raise for handling at next level
End If
Else If LastException.Message.Contains("Copying cancelled") Then
ex.Initialize("Copying cancelled")
ex.Throw ' Re-raise for handling at next level
Else
Msgbox(LastException.Message, "Error Occurred")
End If
End Try
End Sub