Handle multiple errors (somewhat)
FossilOrigin-Name: 2145b0a4409a8f4d6eb5e999b2c7275a34f20a7dede06fddd6f8d360aed765b9
This commit is contained in:
parent
813418a403
commit
71a358001c
2 changed files with 15 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
|||
CC ?= cc
|
||||
CFLAGS = -g -ansi -Wall -Werror=implicit-function-declaration -I ./include/
|
||||
CFLAGS = -g -ansi -Wall -Werror=implicit-function-declaration -I ./include/ `pkg-config --cflags libcjson`
|
||||
SRC = $(wildcard src/*.c)
|
||||
OBJ = $(patsubst %.c,%.o,$(SRC))
|
||||
TARGET = libmastodont.a # shared
|
||||
|
|
14
src/error.c
14
src/error.c
|
@ -16,6 +16,18 @@
|
|||
#include <mastodont_query.h>
|
||||
#include <mastodont_json_helper.h>
|
||||
|
||||
static void _mstdnt_val_errors_call(cJSON* v, void* _type)
|
||||
{
|
||||
char** type = _type;
|
||||
if (v->child && v->child->valuestring)
|
||||
*type = v->child->valuestring;
|
||||
else
|
||||
{
|
||||
*type = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int mstdnt_check_error(struct mstdnt_fetch_results* results,
|
||||
struct mstdnt_storage* storage)
|
||||
{
|
||||
|
@ -28,8 +40,10 @@ int mstdnt_check_error(struct mstdnt_fetch_results* results,
|
|||
storage->error = NULL;
|
||||
storage->error_description = NULL;
|
||||
|
||||
/* TODO I have no idea why multiple errors can be returned */
|
||||
struct _mstdnt_val_ref refs[] = {
|
||||
{ "error", &(storage->error), _mstdnt_val_string_call },
|
||||
{ "errors", &(storage->error), _mstdnt_val_errors_call },
|
||||
{ "error_description", &(storage->error_description), _mstdnt_val_string_call },
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue