aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael McVady <femtonaut@gmail.com>2022-03-10 21:07:10 -0500
committerMichael McVady <femtonaut@gmail.com>2022-03-10 21:07:10 -0500
commit91723dca0ee9bf68b0147dcf233274cd93f911c8 (patch)
tree9821689c75986b52d56ef59cfab719d2c787fa28 /src
parentbbf79174149cf9dde3e08c42d01ba752c6589afe (diff)
Render something on errors
Diffstat (limited to 'src')
-rw-r--r--src/clog.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/clog.c b/src/clog.c
index 36f0a96..9364a2f 100644
--- a/src/clog.c
+++ b/src/clog.c
@@ -13,7 +13,9 @@
#include "../lib/md4c/src/md4c-html.c"
KORE_SECCOMP_FILTER("clog",
- KORE_SYSCALL_ALLOW(getdents64)
+ KORE_SYSCALL_ALLOW(getdents64),
+ KORE_SYSCALL_ALLOW(sendmmsg),
+ KORE_SYSCALL_ALLOW(uname)
)
int init(int);
@@ -68,6 +70,9 @@ render_posts(struct http_request *req, const char *resource)
// Post attributes/query results.
char *id, *title, *created_at, *body;
+ // Start writing HTML.
+ kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html);
+
// Setup SQL
kore_pgsql_init(&sql);
@@ -76,16 +81,18 @@ render_posts(struct http_request *req, const char *resource)
// kore_pgsql_register()). We also say we will perform a synchronous
// query (KORE_PGSQL_SYNC).
err = kore_pgsql_setup(&sql, database, KORE_PGSQL_SYNC);
- kore_log(LOG_ERR, "kore_pgsql_setup: %d", err);
+ kore_log(LOG_DEBUG, "kore_pgsql_setup: %d", err);
if (!err)
{
+ kore_buf_appendf(
+ resp_buf,
+ (const char *) asset_error_html,
+ "There was an error processing the request."
+ );
kore_pgsql_logerror(&sql);
goto out;
}
- // Start writing HTML.
- kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html);
-
// Query for posts, check for error.
if (!resource) {
// Query all posts.
@@ -107,6 +114,11 @@ render_posts(struct http_request *req, const char *resource)
);
}
if (!err) {
+ kore_buf_appendf(
+ resp_buf,
+ (const char *) asset_error_html,
+ "There was an error processing the request."
+ );
kore_pgsql_logerror(&sql);
goto out;
}
@@ -118,7 +130,7 @@ render_posts(struct http_request *req, const char *resource)
title = kore_pgsql_getvalue(&sql, row, 1);
created_at = kore_pgsql_getvalue(&sql, row, 2);
body = kore_pgsql_getvalue(&sql, row, 3);
- kore_log(LOG_NOTICE, "id: '%s'; title '%s'", id, title);
+ kore_log(LOG_DEBUG, "id: '%s'; title '%s'", id, title);
// Allocate a buffer to render the markdown as HTML into.
struct kore_buf *html_buf = kore_buf_alloc(0);