Catch not inspecting the thrown exception

CachéQuality release 
1.0.0
Id 
OS0066
Rule type 
Severity 

Major

Major
SQALE characteristic 
  • Reliability
    • Exception handling
Tags 
coding-guidelines
Remediation function 
Constant/issue
Remediation cost 
10min

ObjectScript allows to write code such as:

    Method m()
    {
        try {
            do ..something()
        } catch {
            write "Oops...", !
        }
    }

In the sample code above, it is assumed that ..something() may throw an exception.

However, the catch block, as it is declared, will only have the knowledge that the try block failed; it will be unable to inspect the thrown exception.

In the best of scenarios, this makes error reporting imprecise. If possible/relevant, consider modifying this code to make the catch block aware of the exception and act on it, as in:

    Method m()
    {
        try {
            do ..something()
        } catch (e) {
            // inspect e
        }
    }