Stop PeopleCode Processing with Error

A blunt, but useful method for debugging PeopleCode is to use the inbuilt "Error" function to stop processing and provide a message.

Something as simple as this can be a valuable debugging tool at times:

Error "The value of variable x=" | &x;

Most people use message box (or the now very deprecated WinMessage), but at times this may not appear depending on the context of the PeopleCode you are executing. Error stops processing (a poor man's breakpoint) so you can find out what's going on at that exact point in the code.

Note: Error causes a rollback of any pending database transactions, so if you need to store the state of the DB, put in a commit (e.g. SQLExec("commit") on Oracle) before throwing the error.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License