From 6889931cdb9a7831482779976b1d3bb8d6e23247 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Tue, 2 Jan 2024 21:21:56 -0600 Subject: Handle errors --- src/clog.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/clog.c') diff --git a/src/clog.c b/src/clog.c index 24e08d0..2705558 100644 --- a/src/clog.c +++ b/src/clog.c @@ -184,7 +184,9 @@ int get_entry_form(struct http_request *req) { int post_entry_form(struct http_request *req) { - struct kore_buf *resp_buf = kore_buf_alloc(0); + int err = 0; + + struct kore_buf *resp_buf = NULL; char *id = NULL; char *title = NULL; @@ -204,6 +206,8 @@ int post_entry_form(struct http_request *req) { kore_log(LOG_INFO, "form body %s.", body); } + resp_buf = kore_buf_alloc(0); + // Append form. kore_buf_appendf( resp_buf, (const char *) asset_entry_edit_html, @@ -211,11 +215,11 @@ int post_entry_form(struct http_request *req) { ); // Render MD. - (void) render_md(body, resp_buf); - // if (err == KORE_RESULT_ERROR) { - // kore_log(LOG_ERR, "Error rendering markdown for entry %s.", id); - // continue; - // } + err = render_md(body, resp_buf); + if (err == KORE_RESULT_ERROR) { + kore_buf_append(resp_buf, "Error rendering markdown.", 25); + kore_log(LOG_ERR, "Error rendering markdown."); + } http_ok_resp(req, HTTP_STATUS_OK, resp_buf); -- cgit v1.2.3