@@ -52,12 +52,12 @@ uint64_t BedrockCore::_getRemainingTime(const unique_ptr<BedrockCommand>& comman
52
52
return isProcessing ? min (processTimeout, adjustedTimeout) : adjustedTimeout;
53
53
}
54
54
55
- bool BedrockCore::isTimedOut (unique_ptr<BedrockCommand>& command) {
55
+ bool BedrockCore::isTimedOut (unique_ptr<BedrockCommand>& command, SQLite* db, const BedrockServer* server ) {
56
56
try {
57
57
_getRemainingTime (command, false );
58
58
} catch (const SException& e) {
59
59
// Yep, timed out.
60
- _handleCommandException (command, e);
60
+ _handleCommandException (command, e, db, server );
61
61
command->complete = true ;
62
62
return true ;
63
63
}
@@ -104,7 +104,7 @@ void BedrockCore::prePeekCommand(unique_ptr<BedrockCommand>& command, bool isBlo
104
104
STHROW (" 555 Timeout prePeeking command" );
105
105
}
106
106
} catch (const SException& e) {
107
- _handleCommandException (command, e);
107
+ _handleCommandException (command, e, &_db, &_server );
108
108
command->complete = true ;
109
109
} catch (...) {
110
110
SALERT (" Unhandled exception typename: " << SGetCurrentExceptionName () << " , command: " << request.methodLine );
@@ -186,7 +186,7 @@ BedrockCore::RESULT BedrockCore::peekCommand(unique_ptr<BedrockCommand>& command
186
186
}
187
187
} catch (const SException& e) {
188
188
command->repeek = false ;
189
- _handleCommandException (command, e);
189
+ _handleCommandException (command, e, &_db, &_server );
190
190
} catch (const SHTTPSManager::NotLeading& e) {
191
191
command->repeek = false ;
192
192
returnValue = RESULT::SHOULD_PROCESS;
@@ -284,7 +284,7 @@ BedrockCore::RESULT BedrockCore::processCommand(unique_ptr<BedrockCommand>& comm
284
284
}
285
285
}
286
286
} catch (const SException& e) {
287
- _handleCommandException (command, e);
287
+ _handleCommandException (command, e, &_db, &_server );
288
288
_db.rollback ();
289
289
needsCommit = false ;
290
290
} catch (const SQLite::constraint_error& e) {
@@ -353,7 +353,7 @@ void BedrockCore::postProcessCommand(unique_ptr<BedrockCommand>& command, bool i
353
353
STHROW (" 555 Timeout postProcessing command" );
354
354
}
355
355
} catch (const SException& e) {
356
- _handleCommandException (command, e);
356
+ _handleCommandException (command, e, &_db, &_server );
357
357
} catch (...) {
358
358
SALERT (" Unhandled exception typename: " << SGetCurrentExceptionName () << " , command: " << request.methodLine );
359
359
command->response .methodLine = " 500 Unhandled Exception" ;
@@ -367,7 +367,7 @@ void BedrockCore::postProcessCommand(unique_ptr<BedrockCommand>& command, bool i
367
367
_db.setQueryOnly (false );
368
368
}
369
369
370
- void BedrockCore::_handleCommandException (unique_ptr<BedrockCommand>& command, const SException& e) {
370
+ void BedrockCore::_handleCommandException (unique_ptr<BedrockCommand>& command, const SException& e, SQLite* db, const BedrockServer* server ) {
371
371
string msg = " Error processing command '" + command->request .methodLine + " ' (" + e.what () + " ), ignoring." ;
372
372
if (!e.body .empty ()) {
373
373
msg = msg + " Request body: " + e.body ;
@@ -396,9 +396,11 @@ void BedrockCore::_handleCommandException(unique_ptr<BedrockCommand>& command, c
396
396
}
397
397
398
398
// Add the commitCount header to the response.
399
- command->response [" commitCount" ] = to_string (_db.getCommitCount ());
399
+ if (db) {
400
+ command->response [" commitCount" ] = to_string (db->getCommitCount ());
401
+ }
400
402
401
- if (_server. args .isSet (" -extraExceptionLogging" )) {
403
+ if (server && server-> args .isSet (" -extraExceptionLogging" )) {
402
404
auto stack = e.details ();
403
405
command->response [" exceptionSource" ] = stack.back ();
404
406
}
0 commit comments