Proper errors

FossilOrigin-Name: 76f78f025964fb3001da55b88fe2afa92ac980de28164933da67ddbada5a554e
This commit is contained in:
me@ow.nekobit.net 2022-04-01 19:35:03 +00:00
parent d20e908f49
commit 45085805f3
2 changed files with 13 additions and 10 deletions

View file

@ -18,6 +18,7 @@
#include <stdlib.h>
#include "base_page.h"
#include "error.h"
#include "../config.h"
#include "account.h"
#include "easprintf.h"
@ -67,12 +68,11 @@ char* construct_account_page(struct mstdnt_account* acct,
void content_account(struct session* ssn, mastodont_t* api, char** data)
{
int cleanup = 0;
char* account_page;
struct mstdnt_account acct;
struct mstdnt_storage storage, status_storage;
struct mstdnt_status* statuses;
size_t status_len;
struct mstdnt_account acct = { 0 };
struct mstdnt_storage storage = { 0 }, status_storage = { 0 };
struct mstdnt_status* statuses = NULL;
size_t status_len = 0;
int lookup_type = config_experimental_lookup ? MSTDNT_LOOKUP_ACCT : MSTDNT_LOOKUP_ID;
if (mastodont_get_account(api, lookup_type, data[0],
@ -80,16 +80,15 @@ void content_account(struct session* ssn, mastodont_t* api, char** data)
mastodont_get_account_statuses(api, acct.id, NULL,
&status_storage, &statuses, &status_len))
{
account_page = "Couldn't load account info";
account_page = construct_error("Couldn't load account info", NULL);
}
else {
cleanup = 1;
account_page = construct_account_page(&acct,
statuses,
status_len,
NULL);
if (!account_page)
account_page = "Malloc error";
exit(EXIT_FAILURE);
}
struct base_page b = {
@ -106,5 +105,5 @@ void content_account(struct session* ssn, mastodont_t* api, char** data)
mastodont_storage_cleanup(&storage);
mastodont_storage_cleanup(&status_storage);
mstdnt_cleanup_statuses(statuses, status_len);
if (cleanup) free(account_page);
free(account_page);
}

View file

@ -53,7 +53,11 @@ int main(void)
struct session ssn = {
.config = {
.changed = 0,
.theme = "treebird20"
.theme = "treebird20",
.themeclr = 0,
.jsactions = 0,
.jsreply = 0,
.jslive = 0
}
};