Skip to content

Commit 8ab09ae

Browse files
committed
Log server handler errors
1 parent 22c2421 commit 8ab09ae

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/wh_server.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,28 @@ 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);
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);
442442

443-
(void)handlerRc; /* Suppress unused variable warning until logging is
444-
* implemented */
443+
/* Log error code from sending response, if present */
444+
WH_LOG_ON_ERROR_F(
445+
&server->log, WH_LOG_LEVEL_ERROR, rc,
446+
"SendResponse failed for (group=%d, action=%d, seq=%d): %d", group,
447+
action, seq, rc);
445448

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

451461
return rc;
452462
}

0 commit comments

Comments
 (0)