diff --git a/CMakeLists.txt b/CMakeLists.txt index 191ee95..8021195 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) include(cmake/color.cmake) -set(BLT_VERSION 0.15.8) +set(BLT_VERSION 0.15.9) set(BLT_TEST_VERSION 0.0.1) set(BLT_TARGET BLT) diff --git a/include/blt/std/error.h b/include/blt/std/error.h new file mode 100644 index 0000000..10545bc --- /dev/null +++ b/include/blt/std/error.h @@ -0,0 +1,29 @@ +#pragma once +/* + * 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 . + */ + +#ifndef BLT_ERROR_H +#define BLT_ERROR_H + +namespace blt::error +{ + + void print_socket_error(); + +} + +#endif //BLT_ERROR_H diff --git a/src/blt/std/error.cpp b/src/blt/std/error.cpp new file mode 100644 index 0000000..566ac4b --- /dev/null +++ b/src/blt/std/error.cpp @@ -0,0 +1,82 @@ +/* + * 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 . + */ +#include +#include + +namespace blt +{ + 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: + BLT_WARN("Cannot assign requested address"); + 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: + BLT_WARN("Socket operation on non-socket"); + break; + case EPROTOTYPE: + BLT_WARN("Protocol wrong type for socket"); + break; + case ETIMEDOUT: + BLT_WARN("Connection timed out"); + break; + } + } +} \ No newline at end of file