From e9e850f798885c528ef9413fd8d12dd0ef9e06c1 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 10 May 2018 20:14:24 +0200 Subject: Move error handling to world --- src/world.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/world.c') 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 + #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) { -- cgit v1.2.1