Merge pull request #6987 from Morph1984/common-error
common: Move error handling functions out of common_funcs
This commit is contained in:
commit
74030eb427
|
@ -53,6 +53,8 @@ add_library(common STATIC
|
||||||
div_ceil.h
|
div_ceil.h
|
||||||
dynamic_library.cpp
|
dynamic_library.cpp
|
||||||
dynamic_library.h
|
dynamic_library.h
|
||||||
|
error.cpp
|
||||||
|
error.h
|
||||||
fiber.cpp
|
fiber.cpp
|
||||||
fiber.h
|
fiber.h
|
||||||
fs/file.cpp
|
fs/file.cpp
|
||||||
|
@ -88,7 +90,6 @@ add_library(common STATIC
|
||||||
microprofile.cpp
|
microprofile.cpp
|
||||||
microprofile.h
|
microprofile.h
|
||||||
microprofileui.h
|
microprofileui.h
|
||||||
misc.cpp
|
|
||||||
nvidia_flags.cpp
|
nvidia_flags.cpp
|
||||||
nvidia_flags.h
|
nvidia_flags.h
|
||||||
page_table.cpp
|
page_table.cpp
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <iterator>
|
||||||
|
|
||||||
#if !defined(ARCHITECTURE_x86_64)
|
#if !defined(ARCHITECTURE_x86_64)
|
||||||
#include <cstdlib> // for exit
|
#include <cstdlib> // for exit
|
||||||
|
@ -49,16 +48,6 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
|
||||||
|
|
||||||
#endif // _MSC_VER ndef
|
#endif // _MSC_VER ndef
|
||||||
|
|
||||||
// Generic function to get last error message.
|
|
||||||
// Call directly after the command or use the error num.
|
|
||||||
// This function might change the error code.
|
|
||||||
// Defined in misc.cpp.
|
|
||||||
[[nodiscard]] std::string GetLastErrorMsg();
|
|
||||||
|
|
||||||
// Like GetLastErrorMsg(), but passing an explicit error code.
|
|
||||||
// Defined in misc.cpp.
|
|
||||||
[[nodiscard]] std::string NativeErrorToString(int e);
|
|
||||||
|
|
||||||
#define DECLARE_ENUM_FLAG_OPERATORS(type) \
|
#define DECLARE_ENUM_FLAG_OPERATORS(type) \
|
||||||
[[nodiscard]] constexpr type operator|(type a, type b) noexcept { \
|
[[nodiscard]] constexpr type operator|(type a, type b) noexcept { \
|
||||||
using T = std::underlying_type_t<type>; \
|
using T = std::underlying_type_t<type>; \
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/error.h"
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
std::string NativeErrorToString(int e) {
|
std::string NativeErrorToString(int e) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -50,3 +52,5 @@ std::string GetLastErrorMsg() {
|
||||||
return NativeErrorToString(errno);
|
return NativeErrorToString(errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Common
|
21
src/common/error.h
Normal file
21
src/common/error.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
// Generic function to get last error message.
|
||||||
|
// Call directly after the command or use the error num.
|
||||||
|
// This function might change the error code.
|
||||||
|
// Defined in error.cpp.
|
||||||
|
[[nodiscard]] std::string GetLastErrorMsg();
|
||||||
|
|
||||||
|
// Like GetLastErrorMsg(), but passing an explicit error code.
|
||||||
|
// Defined in error.cpp.
|
||||||
|
[[nodiscard]] std::string NativeErrorToString(int e);
|
||||||
|
|
||||||
|
} // namespace Common
|
|
@ -2,7 +2,9 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include <string>
|
||||||
|
|
||||||
|
#include "common/error.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/thread.h"
|
#include "common/thread.h"
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -21,8 +23,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
#define cpu_set_t cpuset_t
|
#define cpu_set_t cpuset_t
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "common/common_funcs.h"
|
|
||||||
|
#include "common/error.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
@ -223,7 +224,7 @@ Errno GetAndLogLastError() {
|
||||||
if (err == Errno::AGAIN) {
|
if (err == Errno::AGAIN) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
LOG_ERROR(Network, "Socket operation error: {}", NativeErrorToString(e));
|
LOG_ERROR(Network, "Socket operation error: {}", Common::NativeErrorToString(e));
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string_view>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "video_core/command_classes/nvdec_common.h"
|
#include "video_core/command_classes/nvdec_common.h"
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
|
|
Loading…
Reference in a new issue