Use of $ETRAP

objectscriptQuality release 
1.0.0
Id 
OS0002
Rule type 
Code Smell
Severity 

Blocker

Blocker
SQALE characteristic 
  • Reliability
    • Exception handling
Tags 
confusing, deprecation
Remediation function 
Constant/issue
Remediation cost 
1d

ObjectScript supports try/catch statements. Old code would have to resort to using the $ETRAP system variable, as in:

    new $etrap
    set $etrap = "do somethingElse()"

    // Execute "do somethingElse()" if "do something()" throws an exception
    do something()

This should be replaced with:

    try {
        do something()
    } catch (e) {
        // Perform something with e if needed
        do somethingElse()
    }

See here for more information.