navigation

FailwithBadUsage (FL0072)

Introduced in 0.21.1

Cause

Using failwith in improper places or with dubious parameters.

Rationale

Passing empty strings or duplicate messages to failwith statements makes it much harder to understand/locate & subsequently fix bugs. It's also true when exceptions are swallowed in try...with blocks.

How To Fix

Do not pass an empty string or a duplicate message to failwith. In case of swallowing exception messages in try...with blocks, pass the exception as an innerException parameter of a new Exception: raise <| Exception("Error message", ex).

Rule Settings

{
    "failwithBadUsage": {
       "enabled": true
    }
}