ObjectScript has at least three ways of handling errors (status codes, exceptions, SQLCODE, etc.). Most of the system code uses statuses but exceptions are easier to handle for a number of reasons. Working with legacy code you spend some time translating between the different techniques. I use these snippets a lot for reference. Hopefully they're useful to others as well.
///Status from SQLCODE:set st = $$$ERROR($$$SQLError, SQLCODE, $g(%msg)) //embedded SQLset st = $$$ERROR($$$SQLError, rs.%SQLCODE, $g(rs.%Message)) //dynamic SQL///Exception from SQLCODE:throw ##class(%Exception.

.png)
(1).png)


in the task bar and select 