If you throw a custom error, it can be hard to track down where it came from if you're using a common function. In Reporting file, function and line number in Apps Script I showed how to get back an object with information about where you are, including stack information. Here's a simplified version to add stack information to your custom error messages.
This is available in my cUseful library if you are using that. Otherwise you can just copy the code.
Many of the snippets in this section of the site are part of the cUseful library which you can include in your project. You can find the details below.
See Google Apps Scripts snippets for more like this
You want to learn Google Apps Script?
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Google Apps Scripts snippets >