diff src/core/error.h @ 95:e82eca4f8606

core: simplify error/panic routines
author David Demelier <markand@malikania.fr>
date Mon, 30 Mar 2020 14:07:21 +0200
parents 837ef1d387b4
children
line wrap: on
line diff
--- a/src/core/error.h	Mon Mar 30 13:34:42 2020 +0200
+++ b/src/core/error.h	Mon Mar 30 14:07:21 2020 +0200
@@ -27,12 +27,13 @@
 
 #include <stdarg.h>
 #include <stdbool.h>
-#include <stdnoreturn.h>
+
+#include "plat.h"
 
 /**
  * Get the last error returned.
  *
- * \return the error string
+ * \return The error string.
  */
 const char *
 error(void);
@@ -41,7 +42,7 @@
  * Convenient helper that sets last error from global C errno and then return
  * false.
  *
- * \return false
+ * \return Always false.
  */
 bool
 error_errno(void);
@@ -49,43 +50,22 @@
 /**
  * Set the game error with a printf-like format.
  *
+ * \pre fmt != NULL
  * \param fmt the format string
- * \return false
+ * \return Always false.
  */
 bool
-error_printf(const char *fmt, ...);
+error_printf(const char *fmt, ...) PLAT_PRINTF(1, 2);
 
 /**
  * Similar to \ref error_printf.
  *
+ * \pre fmt != NULL
  * \param fmt the format stinrg
  * \param ap the variadic arguments pointer
- * \return false
+ * \return Always false.
  */
 bool
-error_vprintf(const char *fmt, va_list ap);
-
-/**
- * Print last registered error and exit with code 1.
- */
-noreturn void
-error_fatal(void);
-
-/**
- * Prints an error to stderr and exit with code 1.
- *
- * \param fmt the format string
- */
-noreturn void
-error_fatalf(const char *fmt, ...);
-
-/**
- * Similar to \ref error_fatalf.
- *
- * \param fmt the format string
- * \param ap the variadic arguments pointer
- */
-noreturn void
-error_vfatalf(const char *fmt, va_list ap);
+error_vprintf(const char *fmt, va_list ap) PLAT_PRINTF(1, 0);
 
 #endif /* !MOLKO_ERROR_H */