aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd/error.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/serd/error.h')
-rw-r--r--include/serd/error.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/serd/error.h b/include/serd/error.h
new file mode 100644
index 00000000..7be1d372
--- /dev/null
+++ b/include/serd/error.h
@@ -0,0 +1,45 @@
+// Copyright 2011-2022 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef SERD_ERROR_H
+#define SERD_ERROR_H
+
+#include "serd/attributes.h"
+#include "serd/status.h"
+
+#include <stdarg.h>
+
+SERD_BEGIN_DECLS
+
+/**
+ @defgroup serd_error Error reporting
+ @ingroup serd_errors
+ @{
+*/
+
+/// An error description
+typedef struct {
+ SerdStatus status; ///< Error code
+ const char* SERD_NULLABLE filename; ///< File with error
+ unsigned line; ///< Line in file with error or 0
+ unsigned col; ///< Column in file with error
+ const char* SERD_NONNULL fmt; ///< Printf-style format string
+ va_list* SERD_NONNULL args; ///< Arguments for fmt
+} SerdError;
+
+/**
+ Callback function for errors.
+
+ @param handle Handle for user data.
+ @param error Error description.
+*/
+typedef SerdStatus (*SerdErrorFunc)(void* SERD_NULLABLE handle,
+ const SerdError* SERD_NONNULL error);
+
+/**
+ @}
+*/
+
+SERD_END_DECLS
+
+#endif // SERD_ERROR_H