Add error reporting during library initialization

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2023-10-13 19:57:35 +02:00
parent 78a424b5af
commit b017b02486
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
1 changed files with 15 additions and 2 deletions

View File

@ -341,11 +341,24 @@ void http_init(void)
callbacks.log_access = log_http_access;
callbacks.init_lua = init_lua;
// Prepare error handler
struct mg_error_data error = { 0 };
char error_buffer[1024] = { 0 };
error.text_buffer_size = sizeof(error_buffer);
error.text = error_buffer;
// Prepare initialization data
struct mg_init_data init = { 0 };
init.callbacks = &callbacks;
init.user_data = NULL;
init.configuration_options = options;
/* Start the server */
if((ctx = mg_start(&callbacks, NULL, options)) == NULL)
if((ctx = mg_start2(&init, &error)) == NULL)
{
log_err("Start of webserver failed!. Web interface will not be available!");
log_err(" Check webroot %s and listening ports %s",
log_err(" Error: %s (error code %u.%u)", error.text, error.code, error.code_sub);
log_err(" Hint: Check webroot %s and listening ports %s",
config.webserver.paths.webroot.v.s, config.webserver.port.v.s);
return;
}