diff options
Diffstat (limited to 'src/jsonapi/jsonapi_error.c')
-rw-r--r-- | src/jsonapi/jsonapi_error.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/jsonapi/jsonapi_error.c b/src/jsonapi/jsonapi_error.c index d91f0a650..b7fc08d72 100644 --- a/src/jsonapi/jsonapi_error.c +++ b/src/jsonapi/jsonapi_error.c | |||
@@ -132,6 +132,42 @@ parse_jsonapierror (void *cls, | |||
132 | } | 132 | } |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * Create a JSON API error | ||
136 | * | ||
137 | * @param res the JSON error | ||
138 | */ | ||
139 | struct GNUNET_JSONAPI_Error* | ||
140 | GNUNET_JSONAPI_error_new (const char *id, | ||
141 | const char *status, | ||
142 | const char *code, | ||
143 | const char *title, | ||
144 | const char *detail, | ||
145 | json_t *links, | ||
146 | json_t *source, | ||
147 | json_t *meta) | ||
148 | { | ||
149 | struct GNUNET_JSONAPI_Error *error; | ||
150 | error = GNUNET_new (struct GNUNET_JSONAPI_Error); | ||
151 | |||
152 | GNUNET_assert (NULL != id); | ||
153 | error->id = GNUNET_strdup (id); | ||
154 | GNUNET_assert (NULL != status); | ||
155 | error->status = GNUNET_strdup (status); | ||
156 | GNUNET_assert (NULL != code); | ||
157 | error->code = GNUNET_strdup (code); | ||
158 | GNUNET_assert (NULL != title); | ||
159 | error->title = GNUNET_strdup (title); | ||
160 | GNUNET_assert (NULL != detail); | ||
161 | error->detail = GNUNET_strdup (detail); | ||
162 | GNUNET_assert (NULL != links); | ||
163 | error->links = json_deep_copy (links); | ||
164 | GNUNET_assert (NULL != source); | ||
165 | error->source = json_deep_copy (source); | ||
166 | GNUNET_assert (NULL != meta); | ||
167 | error->meta = json_deep_copy (meta); | ||
168 | return error; | ||
169 | } | ||
170 | /** | ||
135 | * Delete a JSON API error | 171 | * Delete a JSON API error |
136 | * | 172 | * |
137 | * @param res the JSON error | 173 | * @param res the JSON error |