summaryrefslogtreecommitdiff
path: root/src/file/errors/registrator.cpp
blob: 9389179eb98085fc942b08b67cd4725c52e8ce71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <cerrno>

#include "registrator.hpp"
#include "logger/logger_set.hpp"

namespace smtp::file::errors
{

    void Registrator::Add( types::IErrorPtr const& error, int error_code )
    {
        mErrorSet.insert( {error_code, error} );
    }

    void Registrator::Process( types::SettingsType settings_type ) const
    {
        auto find = mErrorSet.find(errno);
        if( find == mErrorSet.end() )
        {
            DefaultProcess(errno);
        }
        find->second->Process( settings_type );
    }

    void Registrator::DefaultProcess(int error_code) const
    {
        static const std::string METHOD = "Open file";

        std::string message = "Unknown error - " + std::to_string(error_code);
        logger::LoggerSet::GetInstance()->LogError( METHOD, message );
    }

}