Skip to content

Missing code in Raise block in "Try ... Raise ... EndTry" (MissingCodeTryCatchEx)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Error BSL
OS
Major Yes 15 standard
badpractice

Parameters

Name Type Description Default value
commentAsCode Boolean Treat comment in Raise section as code false

Description

It is unacceptable to catch any exception, without any trace for system administrator.

Incorrect

Try
    // code causing exception
    ....
Raise // catch any exception
EndTry;

As a rule, such a design hides a real problem, which is subsequently impossible to diagnose.

Correct

Try
    // code causing exception
    ....
Raise
    // Explanation why catching all exceptions untraceable for enduser.
    // ....
    // Write to log for system administrator.
    WriteLogEvent(NStr("en = 'Action'"),
       EventLogLevel.Error,,,
       DetailErrorDescription(ErrorInfo()));
EndTry;

Sources

Snippets

Diagnostic ignorance in code

// BSLLS:MissingCodeTryCatchEx-off
// BSLLS:MissingCodeTryCatchEx-on

Parameter for config

"MissingCodeTryCatchEx": {
    "commentAsCode": false
}