InterSystems FAQ rubric
If you want to raise an arbitrary custom error in a TRY block, you can pass an exception with a throw as follows. In the following example, a custom error is raised if Stcount is less than 1.
Class User.Test
{
ClassMethod ExceptionTest()
{
try
{
// : some codesif (Stcount<1) {
throw##class(%Exception.General).%New("User-defined error", "5001", "location", "Data at location error")
// User-created errors are 5001 and above
}
}
catch ex
{
write"Errors #", ex.Code, ": ", ex.Name, " : ", e
.png)
.png)
.png)
.png)

.png)
.png)

