void HandleSignal(int signal) { const char* sigtype[NSIG]; sigtype[SIGABRT] = "SIGABRT"; sigtype[SIGFPE] = "SIGFPE"; sigtype[SIGILL] = "SIGILL"; sigtype[SIGSEGV] = "SIGSEGV"; std::string stackTrace; stackTrace += "signal = "; stackTrace += sigtype[signal]; stackTrace += "\n"; stackTrace += gPlaytomic->GetDevice(); std::string extraInfo( " "); if(CExceptionHandler::mCallback) { CExceptionHandler::mCallback(signal, extraInfo); } CExceptionHandler::GetStackTrace(stackTrace); stackTrace += "\n\ngame infromation: \n"; stackTrace += extraInfo; CExceptionHandler::SendStackTrace(stackTrace.c_str()); CExceptionHandler::UnsetHandlers(); }
TEST(GetStatusFromCommandResult, ExtraInfoParserSucceeds) { ErrorExtraInfoExample::EnableParserForTest whenInScope; const auto status = statusFor("{ok: 0.0, code: 236, errmsg: 'oh no!', data: 123}"); ASSERT_EQ(status, ErrorCodes::ForTestingErrorExtraInfo); ASSERT_EQ(status.reason(), "oh no!"); ASSERT(status.extraInfo()); ASSERT(status.extraInfo<ErrorExtraInfoExample>()); ASSERT_EQ(status.extraInfo<ErrorExtraInfoExample>()->data, 123); }
TEST(GetStatusFromCommandResult, ExtraInfoParserFails) { const auto status = statusFor("{ok: 0.0, code: 236, errmsg: 'oh no!', data: 123}"); ASSERT_EQ(status, ErrorCodes::duplicateCodeForTest(40681)); ASSERT(!status.extraInfo()); }
TEST(GetStatusFromCommandResult, SimpleNoCode) { const auto status = statusFor("{ok: 0.0, errmsg: 'oh no!'}"); ASSERT_EQ(status, ErrorCodes::UnknownError); ASSERT_EQ(status.reason(), "oh no!"); ASSERT(!status.extraInfo()); }