Skip to content

Commit 444974e

Browse files
committed
improve error handling and fix build
1 parent 3b948c3 commit 444974e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

extensions/bingtranslate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ std::pair<bool, std::wstring> Translate(const std::wstring& text)
113113
FormatString(L"/ttranslatev3?fromLang=%s&to=%s&text=%s%s", translateFrom.Copy(), translateTo.Copy(), Escape(text), token.Copy()).c_str()
114114
})
115115
if (auto translation = Copy(JSON::Parse(httpRequest.response)[0][L"translations"][0][L"text"].String())) return { true, translation.value() };
116-
else return { false, FormatString(L"%s: %s", TRANSLATION_ERROR, httpRequest.response) };
116+
else return { false, FormatString(L"%s (token=%s): %s", TRANSLATION_ERROR, std::exchange(token.Acquire().contents, L""), httpRequest.response) };
117117
else return { false, FormatString(L"%s (code=%u)", TRANSLATION_ERROR, httpRequest.errorCode) };
118118
}

extensions/devtools.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern Settings settings;
2121
namespace
2222
{
2323
QLabel* statusLabel;
24-
AutoHandle<> process;
24+
AutoHandle<> process = NULL;
2525
QWebSocket webSocket;
2626
std::atomic<int> idCounter = 0;
2727
Synchronized<std::unordered_map<int, concurrency::task_completion_event<JSON::Value<wchar_t>>>> mapQueue;
@@ -161,7 +161,7 @@ namespace DevTools
161161
int id = idCounter += 1;
162162
if (!Connected()) return {};
163163
mapQueue->try_emplace(id, response);
164-
QMetaObject::invokeMethod(&webSocket, std::bind(&QWebSocket::sendTextMessage, webSocket, S(FormatString(LR"({"id":%d,"method":"%S","params":%s})", id, method, params))));
164+
QMetaObject::invokeMethod(&webSocket, std::bind(&QWebSocket::sendTextMessage, &webSocket, S(FormatString(LR"({"id":%d,"method":"%S","params":%s})", id, method, params))));
165165
try { if (auto result = create_task(response).get()[L"result"]) return result; } catch (...) {}
166166
return {};
167167
}

0 commit comments

Comments
 (0)