We sometimes come across issues with EatDrinkSlay - which is huge by now, probably 10,000 lines at least. We did instil some practices like Batvink has, which makes a big difference - usually a crash will be about a sprite not existing, whereas before we'd get the silent crashes.
Some things we do to try and avoid errors:
Arrays and media are cleaned out as much as possible, like clearing out game media when going back to the main menu.
Function parameters are stored before being passed - mostly we avoid referencing arrays (esp typed arrays) in function calls.
Checks to ensure that arrays are never overflown - like with fixed size arrays especially.
Decide on an ID allocation system and stick to it - for example sprites, either use fixed ID's or auto-ID's, but don't ever mix the 2... same applies to images and objects and anything that has auto-ID. Personally I'd say that any project over 1000 lines should avoid using auto-ID's, it just becomes too messy and unpredictable - make your own media ID system that you can easily add extra control functions to, replace the AppGameKit auto-ID with your own custom one... I mean we end up having to keep track of ID numbers in arrays regardless, so might as well go the whole hog.
Be mindful of the order that you delete media in, I mean if your gonna delete an image, make sure any sprites using that image are deleted first.
Some of this stuff will have no positive impact, but it's a safety thing to avoid the possibility of issues. The project is going onto AGK2 soon which should make things much easier to work with, especially once that debugger makes it in - but I really think it's a good idea to get your project working as best it can in v1 first - because at least then you know that any issues are new issues, not just old bugs that v1 might not have been reporting very efficiently.
I am the one who knocks...