Avoid empty catch sections このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。
このルールを試す ID: csharp-best-practices/no-empty-catch
Language: C#
Severity: Warning
Category: Best Practices
Description Exceptions must be appropriately handled and have code to recover from the exceptions. If no recovery is added, the code should at least log the error.
Non-Compliant Code Examples class MyClass {
public static void routine ()
{
try {
doSomething ();
} catch ( MyException ex ) {
}
}
}
class MyClass {
public static void routine ()
{
try {
doSomething ();
} catch ( MyException ex ) {
// comment
}
}
}
Compliant Code Examples class MyClass {
public static void routine ()
{
try {
doSomething ();
} catch ( MyException ex ) {
handleException ();
}
}
}
Seamless integrations. Try Datadog Code Analysis