What will you do if the error registration error failed, and how do you test its work in production?

  • What do you do if you are mistaken in the error registration code?
  • How do you make sure it is running at the moment?
  • How do you know if it works?
  • How do you verify that it works in a production environment?
  • Should an exception be thrown if all else fails?

The code below uses the Microsoft Enterprise Logging Application Block. How do you do it "better"?

using Microsoft.Practices.EnterpriseLibrary.Logging;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // Trying to write some data to the DB
            ...
        }
        catch (Exception ex)
        {
            LogHelper.LogException(ex, "Trying to write to the DB");
        }
    }
}

public class LogHelper
{
    public static void LogException(Exception ex, string exceptionType)
    {
        try
        {
            // Simplified version, only logging the message
            Logger.Write(exceptionType);
        }
        catch
        {
            // What do you do here???
        }
    }
}
+3
source share
3 answers

See the answers in my related question :

, " " catch. , . , , , , .

() .

+2

. - ( ). , .

, , .

, , .

, , IMHO.

+4

, , . , , , , . , , . 3 . , db catch, , , , - db. , catch db. - , , , .

0
source

Source: https://habr.com/ru/post/1705735/


All Articles