Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
fml
platform
win
errors_win.cc
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#include "flutter/fml/platform/win/errors_win.h"
6
7
#include <Windows.h>
8
9
#include <sstream>
10
11
#include "flutter/fml/platform/win/wstring_conversion.h"
12
13
namespace
fml
{
14
15
std::string
GetLastErrorMessage
() {
16
DWORD
last_error =
::GetLastError
();
17
if
(last_error == 0) {
18
return
{};
19
}
20
21
const
DWORD
flags
= FORMAT_MESSAGE_ALLOCATE_BUFFER |
22
FORMAT_MESSAGE_FROM_SYSTEM |
23
FORMAT_MESSAGE_IGNORE_INSERTS;
24
25
wchar_t
*
buffer
=
nullptr
;
26
size_t
size
= ::FormatMessage(
27
flags
,
// dwFlags
28
NULL,
// lpSource
29
last_error,
// dwMessageId
30
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
// dwLanguageId
31
(LPWSTR)&
buffer
,
// lpBuffer
32
0,
// nSize
33
NULL
// Arguments
34
);
35
36
std::wstring
message
(
buffer
,
size
);
37
38
::LocalFree(
buffer
);
39
40
std::wstringstream stream;
41
stream <<
message
<<
" ("
<< last_error <<
")."
;
42
43
return
WideStringToUtf8
(stream.str());
44
}
45
46
}
// namespace fml
flags
FlutterSemanticsFlag flags
Definition
fl_accessible_node.cc:105
buffer
static const uint8_t buffer[]
Definition
fl_pixel_buffer_texture_test.cc:44
message
Win32Message message
Definition
keyboard_unittests.cc:139
fml
Definition
ascii_trie.cc:9
fml::size
constexpr std::size_t size(T(&array)[N])
Definition
size.h:13
fml::GetLastErrorMessage
std::string GetLastErrorMessage()
Definition
errors_win.cc:15
fml::WideStringToUtf8
std::string WideStringToUtf8(const std::wstring_view str)
Definition
wstring_conversion.cc:16
GetLastError
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)
DWORD
unsigned long DWORD
Definition
windows_types.h:22
Generated on Fri Apr 26 2024 06:14:06 for Flutter Engine by
1.9.8