Skip to content

Commit ed9143f

Browse files
committed
Log server handler errors
1 parent 9a70643 commit ed9143f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/wh_server.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,29 @@ int wh_Server_HandleRequestMessage(whServerContext* server)
435435
size, data);
436436
} while (rc == WH_ERROR_NOTREADY);
437437

438-
/* Log any communication errors */
439-
WH_LOG_ON_ERROR_F(&server->log, WH_LOG_LEVEL_ERROR, rc,
440-
"SendResponse failed for (group=%d, action=%d): %d",
441-
group, action, rc);
442-
443-
(void)handlerRc; /* Suppress unused variable warning until logging is
444-
* implemented */
438+
/* Log error code from request handler, if present */
439+
WH_LOG_ON_ERROR_F(&server->log, WH_LOG_LEVEL_ERROR, handlerRc,
440+
"Handler (group=%d, action=%d, seq=%d) returned %d",
441+
group, action, seq, handlerRc);
442+
(void)handlerRc; /* suppress unused var warning */
443+
444+
/* Log error code from sending response, if present */
445+
WH_LOG_ON_ERROR_F(
446+
&server->log, WH_LOG_LEVEL_ERROR, rc,
447+
"SendResponse failed for (group=%d, action=%d, seq=%d): %d", group,
448+
action, seq, rc);
445449

446450
/* Always return success when we processed a request, so no handler
447451
* error can terminate the server's request processing loop. */
448452
rc = WH_ERROR_OK;
449453
}
454+
else if (rc != WH_ERROR_NOTREADY) {
455+
/* Log error code from processing request, if present */
456+
WH_LOG_ON_ERROR_F(
457+
&server->log, WH_LOG_LEVEL_ERROR, rc,
458+
"RecvRequest failed for (group=%d, action=%d, seq=%d): %d", group,
459+
action, seq, rc);
460+
}
450461

451462
return rc;
452463
}

0 commit comments

Comments
 (0)