I have a more basic set of custom functions to handle errors in my scripting, but many of the patterns I use are similar to the ones introduced in CLEW by people at Soliant.
You can see a presentation here: https://youtu.be/d4N7d0Kdxqs
The material is available here: GitHub - soliantconsulting/clew: clew is a Filemaker error trapping technique that generates a pseudo script stack trace