Part of what I find really hard with Bash scripts is encapsulation and error handling. It all became a tiny bit better when I discovered how I can print the call stack when something occurs. Check out this blog post for how to print the call stack.
I’m thinking this fits nicely with trap, but I’ll have to try that another day. 🙂