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>2018-11-25 22:12:46 +0100
commit4dba05e7ab2cd3caa3fd9c6872b7e21b39bb8ead (patch)
treee410cfcdea0dcd2f2e8ed5c02e81742e31149cbe /src/world.c
parentbcf32f9b340083c97dc2c2b144b971bb1de06a23 (diff)
downloadserd-4dba05e7ab2cd3caa3fd9c6872b7e21b39bb8ead.tar.gz
serd-4dba05e7ab2cd3caa3fd9c6872b7e21b39bb8ead.tar.bz2
serd-4dba05e7ab2cd3caa3fd9c6872b7e21b39bb8ead.zip
Move error handling to world
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/world.c b/src/world.c
index 07439137..0210760d 100644
--- a/src/world.c
+++ b/src/world.c
@@ -16,8 +16,33 @@
#include "serd_internal.h"
+#include <stdarg.h>
+
#include "world.h"
+SerdStatus
+serd_world_error(const SerdWorld* world, const SerdError* e)
+{
+ if (world->error_sink) {
+ world->error_sink(world->error_handle, e);
+ } else {
+ fprintf(stderr, "error: %s:%u:%u: ", e->filename, e->line, e->col);
+ 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)
{