MCPcopy Create free account
hub / github.com/ByConity/ByConity / main

Method main

programs/client/Client.cpp:354–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352
353
354 int main(const std::vector<std::string> & /*args*/) override
355 {
356 try
357 {
358 return mainImpl();
359 }
360 catch (const Exception & e)
361 {
362 bool print_stack_trace = config().getBool("stacktrace", false);
363
364 std::string text = e.displayText();
365
366 /** If exception is received from server, then stack trace is embedded in message.
367 * If exception is thrown on client, then stack trace is in separate field.
368 */
369
370 auto embedded_stack_trace_pos = text.find("Stack trace");
371 if (std::string::npos != embedded_stack_trace_pos && !print_stack_trace)
372 text.resize(embedded_stack_trace_pos);
373
374 std::cerr << "Code: " << e.code() << ". " << text << std::endl << std::endl;
375
376 /// Don't print the stack trace on the client if it was logged on the server.
377 /// Also don't print the stack trace in case of network errors.
378 if (print_stack_trace && e.code() != ErrorCodes::NETWORK_ERROR && std::string::npos == embedded_stack_trace_pos)
379 {
380 std::cerr << "Stack trace:" << std::endl << e.getStackTraceString();
381 }
382
383 /// If exception code isn't zero, we should return non-zero return code anyway.
384 return e.code() ? e.code() : -1;
385 }
386 catch (...)
387 {
388 std::cerr << getCurrentExceptionMessage(false) << std::endl;
389 return getCurrentExceptionCode();
390 }
391 }
392
393 /// Should we celebrate a bit?
394 static bool isNewYearMode()

Callers

nothing calls this directly

Calls 10

getCurrentExceptionCodeFunction · 0.85
displayTextMethod · 0.80
getStackTraceStringMethod · 0.80
mainImplFunction · 0.50
configFunction · 0.50
getBoolMethod · 0.45
findMethod · 0.45
resizeMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected