diff options
author | default <nobody@localhost> | 2023-03-01 08:25:36 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2023-03-01 08:25:36 +0100 |
commit | d75a22adab5b93c0705b9f58fe660d82219ad573 (patch) | |
tree | 85db34cf165305d6a751e30a55464692deb2d966 /data.c | |
parent | 105683d4d2a58f715727af20f3e71efed2c4c927 (diff) |
New function srv_archive_error().
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -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); + } +} |