2023-02-05 12:27:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
2023-08-30 17:19:29 +10:00
|
|
|
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
|
2024-12-08 22:00:56 +05:00
|
|
|
* Copyright (c) 2024-2025, stasoid <stasoid@yahoo.com>
|
2023-02-05 12:27:38 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/Error.h>
|
2025-05-10 16:30:36 -04:00
|
|
|
|
2023-08-30 17:19:29 +10:00
|
|
|
#ifdef AK_OS_WINDOWS
|
|
|
|
# include <AK/ByteString.h>
|
|
|
|
# include <AK/HashMap.h>
|
|
|
|
# include <windows.h>
|
2024-12-08 22:00:56 +05:00
|
|
|
// Comment to prevent clang-format from including windows.h too late
|
|
|
|
# include <winbase.h>
|
2023-08-30 17:19:29 +10:00
|
|
|
#endif
|
2023-02-05 12:27:38 +02:00
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
2023-08-30 17:19:29 +10:00
|
|
|
#ifdef AK_OS_WINDOWS
|
2025-04-04 09:08:13 +02:00
|
|
|
Error Error::from_windows_error(u32 windows_error)
|
2023-08-30 17:19:29 +10:00
|
|
|
{
|
2025-04-04 09:08:13 +02:00
|
|
|
return Error(static_cast<int>(windows_error), Error::Kind::Windows);
|
2024-12-08 22:00:56 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
// This can be used both for generic Windows errors and for winsock errors because WSAGetLastError is forwarded to GetLastError.
|
|
|
|
Error Error::from_windows_error()
|
|
|
|
{
|
|
|
|
return from_windows_error(GetLastError());
|
2023-08-30 17:19:29 +10:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-02-05 12:27:38 +02:00
|
|
|
}
|