summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-03-01 08:25:36 +0100
committerdefault <nobody@localhost>2023-03-01 08:25:36 +0100
commitd75a22adab5b93c0705b9f58fe660d82219ad573 (patch)
tree85db34cf165305d6a751e30a55464692deb2d966 /data.c
parent105683d4d2a58f715727af20f3e71efed2c4c927 (diff)
New function srv_archive_error().
Diffstat (limited to 'data.c')
-rw-r--r--data.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/data.c b/data.c
index 439c15e..8934f31 100644
--- a/data.c
+++ b/data.c
@@ -1844,3 +1844,33 @@ void srv_archive(const char *direction, xs_dict *req,
}
}
}
+
+
+void srv_archive_error(const char *prefix, const xs_str *err,
+ const xs_dict *req, const xs_dict *data)
+/* archives an error */
+{
+ xs *ntid = tid(0);
+ xs *fn = xs_fmt("%s/error/%s_%s", srv_basedir, prefix, ntid);
+ FILE *f;
+
+ if ((f = fopen(fn, "w")) != NULL) {
+ fprintf(f, "Error: %s\n", err);
+
+ if (req) {
+ fprintf(f, "Request headers:\n");
+
+ xs *j = xs_json_dumps_pp(req, 4);
+ fwrite(j, strlen(j), 1, f);
+ }
+
+ if (data) {
+ fprintf(f, "Data:\n");
+
+ xs *j = xs_json_dumps_pp(data, 4);
+ fwrite(j, strlen(j), 1, f);
+ }
+
+ fclose(f);
+ }
+}