If I'm not mistaken you could also use sys_marker.
sys_marker("AAA");
// ... first code section ...
sys_marker("BBB");
// ... second code section ...
sys_marker(NULL);
If an error occurs in the first code section, the error message should contain "AAA"; if an error occurs in the second section, the message should contain "BBB".
I've never used it though, and don't know whether it actually works that way.