Repo-Init
 
Loading...
Searching...
No Matches
ErrorHelpers.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <atomic>
5#include <cstring>
6#include <memory>
7#include <string>
8#include <vector>
9
11// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
12extern std::vector<std::pair<std::string, std::shared_ptr<std::atomic_flag>>> vCheckFlag;
13
14// Alpine Linux incorrectly declares strerror_r
15// https://stackoverflow.com/questions/41953104/strerror-r-is-incorrectly-declared-on-alpine-linux
16char *checkError(int /*unused*/, char *buffer, int /*unused*/);
17char *checkError(char *result, const char * /*unused*/, int /*unused*/);
18
24inline std::string getErrnoString(int errVal)
25{
26 std::array<char, BUFSIZ> buffer{};
27 return checkError(strerror_r(errVal, buffer.data(), BUFSIZ), buffer.data(), errVal);
28}
char * checkError(int, char *buffer, int)
std::string getErrnoString(int errVal)
std::vector< std::pair< std::string, std::shared_ptr< std::atomic_flag > > > vCheckFlag
Global variable to check if the servers are running.