aboutsummaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-10 20:14:24 +0200
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:05 -0500
commita4f6754a4048f2bcb04482938d5a98e9ab77d4fc (patch)
tree5a9ee51f51ae4a1c7116d94cc833f10a5532ff87 /src/world.c
parent10c706a040abeaf5c82db54086d4edb03a995cf3 (diff)
downloadserd-a4f6754a4048f2bcb04482938d5a98e9ab77d4fc.tar.gz
serd-a4f6754a4048f2bcb04482938d5a98e9ab77d4fc.tar.bz2
serd-a4f6754a4048f2bcb04482938d5a98e9ab77d4fc.zip
Move error handling to world
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/world.c b/src/world.c
index 6f5a26c1..f74513da 100644
--- a/src/world.c
+++ b/src/world.c
@@ -16,8 +16,37 @@
#include "world.h"
+#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
+SerdStatus
+serd_world_error(const SerdWorld* world, const SerdError* e)
+{
+ if (world->error_func) {
+ world->error_func(world->error_handle, e);
+ } else {
+ if (e->filename) {
+ fprintf(stderr, "error: %s:%u:%u: ", e->filename, e->line, e->col);
+ } else {
+ fprintf(stderr, "error: ");
+ }
+ vfprintf(stderr, e->fmt, *e->args);
+ }
+ return e->status;
+}
+
+SerdStatus
+serd_world_errorf(const SerdWorld* world, SerdStatus st, const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ const SerdError e = {st, NULL, 0, 0, fmt, &args};
+ serd_world_error(world, &e);
+ va_end(args);
+ return st;
+}
+
SerdWorld*
serd_world_new(void)
{