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>2022-01-13 23:03:47 -0500
commit68769abbf1c7b4ef4f03f93f0c50e016c709a167 (patch)
treee9710eb4b4cf0d2d78de29efd347849e246defc9 /src/world.c
parent71c950bb749c3581ab389edfff9771cb06242e29 (diff)
downloadserd-68769abbf1c7b4ef4f03f93f0c50e016c709a167.tar.gz
serd-68769abbf1c7b4ef4f03f93f0c50e016c709a167.tar.bz2
serd-68769abbf1c7b4ef4f03f93f0c50e016c709a167.zip
Move error handling to world
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/world.c b/src/world.c
index 5663c182..aa260e37 100644
--- a/src/world.c
+++ b/src/world.c
@@ -16,8 +16,40 @@
#include "world.h"
+#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
+SerdStatus
+serd_world_error(const SerdWorld* const world, const SerdError* const 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* const world,
+ const SerdStatus st,
+ const char* const 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)
{