BLT/src/blt/std/error.cpp

82 lines
2.7 KiB
C++
Raw Normal View History

2024-03-31 13:56:56 -04:00
/*
* Copyright (C) 2024 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <blt/std/error.h>
#include <blt/std/logging.h>
2024-03-31 13:57:42 -04:00
namespace blt::error
2024-03-31 13:56:56 -04:00
{
void print_socket_error()
{
switch (errno)
{
case EINVAL:
BLT_WARN("Invalid argument");
break;
case EACCES:
BLT_WARN("Permission denied");
break;
case EPERM:
BLT_WARN("Operation not permitted");
break;
case EADDRINUSE:
BLT_WARN("Address already in use");
break;
case EADDRNOTAVAIL:
2024-09-01 21:55:29 -04:00
BLT_WARN("Cannot copy_fast requested address");
2024-03-31 13:56:56 -04:00
break;
case EAFNOSUPPORT:
BLT_WARN("Address family not supported by protocol");
break;
case EAGAIN:
BLT_WARN("Try again");
break;
case EALREADY:
BLT_WARN("Operation already in progress");
break;
case EBADF:
BLT_WARN("Bad file number");
break;
case ECONNREFUSED:
BLT_WARN("Connection refused");
break;
case EFAULT:
BLT_WARN("Bad address");
break;
case EINPROGRESS:
BLT_WARN("Operation now in progress");
break;
case EINTR:
BLT_WARN("Interrupted system call");
break;
case EISCONN:
BLT_WARN("Transport endpoint is already connected");
break;
case ENETUNREACH:
BLT_WARN("Network is unreachable");
break;
case ENOTSOCK:
2024-06-19 13:07:39 -04:00
BLT_WARN("Socket operation_t on non-socket");
2024-03-31 13:56:56 -04:00
break;
case EPROTOTYPE:
BLT_WARN("Protocol wrong type for socket");
break;
case ETIMEDOUT:
BLT_WARN("Connection timed out");
break;
}
}
}