Small nitpicking: You can shorten your message generation code by doing this:
Code:
diag(str_printf(NULL, "\nError %d: %s", errorCode, _chr(str)));



Also solves the undefined behaviour that you are generating there laugh


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com