| 337 | } |
| 338 | |
| 339 | void Application::handleError( |
| 340 | const QString &message, SyncthingErrorCategory category, int networkError, const QNetworkRequest &request, const QByteArray &response) |
| 341 | { |
| 342 | CPP_UTILITIES_UNUSED(category) |
| 343 | CPP_UTILITIES_UNUSED(networkError) |
| 344 | |
| 345 | // skip error handling for shell completion |
| 346 | if (!m_argsRead) { |
| 347 | return; |
| 348 | } |
| 349 | |
| 350 | // print error message and relevant request and response if present |
| 351 | cerr << Phrases::Override << Phrases::Error << message.toLocal8Bit().data() << Phrases::End; |
| 352 | const auto url = request.url(); |
| 353 | if (!url.isEmpty()) { |
| 354 | cerr << "Request: " << url.toString(QUrl::PrettyDecoded).toLocal8Bit().data() << '\n'; |
| 355 | } |
| 356 | if (!response.isEmpty()) { |
| 357 | cerr << "Response:\n"; |
| 358 | cerr.write(response.data(), response.size()); |
| 359 | if (!response.endsWith('\n')) { |
| 360 | cerr << '\n'; |
| 361 | } |
| 362 | } |
| 363 | cerr << flush; |
| 364 | QCoreApplication::exit(-3); |
| 365 | } |
| 366 | |
| 367 | void Application::requestLog(const ArgumentOccurrence &) |
| 368 | { |