AOP

Exceptions and error logging

Posted on Updated on

At my current work I see an awful lot of code that looks like this:

public class ServiceA : IServiceA
{
    private readonly ILogger _logger;

    public ServiceA(ILogger logger)
    {
        _logger = logger;
    }

    public void DoIt()
    {
        try
        {
            // Do something...
        }
        catch(Exception e)
        {
            _logger.LogError(e);
            throw;
        }
    }    
}

At first blush this looks reasonable: it has constructor-based dependency injection, an abstraction, error logging… What could my issue be?

Read the rest of this entry »