I’ve recently been re-writing some my code to use custom Exceptions. However I’m beginning to feel that this was a design mistake.
Try
~ Do Something
Catch err as myException
#if appMode = editor then
// Write error to log, so all errors are shown at the end.
#else
// Report error and exit method
return
#endif
End Try
The problem I’m running into is that this method contains several of these blocks and when the app is in editor mode, I want to continue processing the rest of the code in this function, but when it’s in client mode I want it to abandon there and then.
I see from the language reference that I can use Finally
but then that requires nested Try/Catch blocks and to be honest I try to avoid nested anything as much as I can. Thoughts?
Nested:
// --- Try first thing.
Try
~ Do Something
Catch err as myException
#if appMode = editor then
// Write error to log, so all errors are shown at the end.
#else
// Report error and exit method
return
#endif
Finally
// --- Now try second thing.
Try
~ Do Something
Catch err as myException
#if appMode = editor then
// Write error to log, so all errors are shown at the end.
#else
// Report error and exit method
return
#endif
Finally
// --- Now try third thing.
Try
~ Do Something
Catch err as myException
#if appMode = editor then
// Write error to log, so all errors are shown at the end.
#else
// Report error and exit method
return
#endif
End Try
End Try
End Try
Unnested code
[code]Try
~ Do Something
Catch err as myException
#if appMode = editor then
// Write error to log, so all errors are shown at the end.
#else
// Report error and exit method
return
#endif
End Try
// — Now try second thing
Try
~ Do Something
Catch err as myException
#if appMode = editor then
// Write error to log, so all errors are shown at the end.
#else
// Report error and exit method
return
#endif
End Try
// — Now try third thing.
Try
~ Do Something
Catch err as myException
#if appMode = editor then
// Write error to log, so all errors are shown at the end.
#else
// Report error and exit method
return
#endif
End Try
[/code]