BSL028 — Missing code in Raise block in "Try ... Raise ... EndTry"¶
Summary¶
Missing code in Raise block in "Try ... Raise ... EndTry"
Identifiers¶
| Field | Value |
|---|---|
| Rule code | BSL028 |
| Compatible alias | MissingCodeTryCatchEx |
| Severity | INFORMATION |
| Enabled by default | Yes |
| Implemented | Yes |
| Tags | error-handling, robustness |
Behavior¶
- The public identifier
BSL028and aliasMissingCodeTryCatchExare stable. - The rule reports the cases documented on this page.
- Suppressions and project configuration are applied before publication.
- The rule requires neither an external analyzer nor network access.
Configuration and suppression¶
BSL### is the primary stable identifier. The compatible alias is accepted
in select, ignore, and compatible block suppression comments.
All three suppression families support both a current line and a range. When an opening comment follows code, it affects only that line. Use any one form:
noqa:
bsl-disable:
- compatible
BSLLSform:
When the same opening comment is on a line by itself, it starts a range. Close it with the matching marker from the same family:
// noqa: BSL028
// code without this diagnostic
// noqa-enable: BSL028
// bsl-disable: BSL028
// code without this diagnostic
// bsl-enable: BSL028
// BSLLS:MissingCodeTryCatchEx-off
// code without this diagnostic
// BSLLS:MissingCodeTryCatchEx-on
To disable the rule until the end of the file, omit the closing
noqa-enable, bsl-enable, or BSLLS:…-on marker.
Opening and closing markers must belong to the same family.
Description¶
It is unacceptable to catch any exception, without any trace for system administrator.
Incorrect
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;