Flutter Engine
The Flutter Engine
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
13namespace fml {
14
15std::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
FlutterSemanticsFlag flags
Win32Message message
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
Definition: ascii_trie.cc:9
constexpr std::size_t size(T(&array)[N])
Definition: size.h:13
std::string GetLastErrorMessage()
Definition: errors_win.cc:15
std::string WideStringToUtf8(const std::wstring_view str)
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)
unsigned long DWORD
Definition: windows_types.h:22