diff options
author | David Robillard <d@drobilla.net> | 2018-05-10 20:14:24 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-06-21 18:12:03 +0200 |
commit | 4d310d89521c97ddcb683986cbe8e860457fe73a (patch) | |
tree | 494e1396abed0223f077ddc0936c8545e667e79e /src/world.c | |
parent | f814ec24583a2dc11fc70421aec1aeb950a78244 (diff) | |
download | serd-4d310d89521c97ddcb683986cbe8e860457fe73a.tar.gz serd-4d310d89521c97ddcb683986cbe8e860457fe73a.tar.bz2 serd-4d310d89521c97ddcb683986cbe8e860457fe73a.zip |
Move error handling to world
Diffstat (limited to 'src/world.c')
-rw-r--r-- | src/world.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/world.c b/src/world.c index 483a33af..1d59a64e 100644 --- a/src/world.c +++ b/src/world.c @@ -16,8 +16,33 @@ #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_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) { |