From a2bf45329a172d2c53594c64d27f1c15ac26796a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 28 Feb 2011 16:28:21 -0500 Subject: New dmnsn_warning() API, remove different severities. --- libdimension/dimension/error.h | 55 +++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) (limited to 'libdimension/dimension') diff --git a/libdimension/dimension/error.h b/libdimension/dimension/error.h index e2fd612..db4197b 100644 --- a/libdimension/dimension/error.h +++ b/libdimension/dimension/error.h @@ -29,24 +29,21 @@ #ifndef DIMENSION_ERROR_H #define DIMENSION_ERROR_H -/** Error severity codes. */ -typedef enum dmnsn_severity { - DMNSN_SEVERITY_LOW, /**< Only die on low resilience. */ - DMNSN_SEVERITY_MEDIUM, /**< Die on low or medium resilience. */ - DMNSN_SEVERITY_HIGH /**< Always die. */ -} dmnsn_severity; +#include + +/** + * Report a warning. + * @param[in] str A string to print explaining the warning. + */ +#define dmnsn_warning(str) \ + dmnsn_report_error(false, DMNSN_FUNC, __FILE__, __LINE__, str) /** * Report an error. - * @param[in] severity A @ref dmnsn_severity representing the severity of the - * error. DMNSN_SEVERITY_HIGH will always terminate the - * running thread. * @param[in] str A string to print explaining the error. */ -#define dmnsn_error(severity, str) \ - dmnsn_report_error((dmnsn_severity)(severity), \ - DMNSN_FUNC, __FILE__, __LINE__, \ - str) +#define dmnsn_error(str) \ + dmnsn_report_error(true, DMNSN_FUNC, __FILE__, __LINE__, str) /** * @def dmnsn_assert @@ -60,36 +57,28 @@ typedef enum dmnsn_severity { #define dmnsn_assert(expr, str) \ do { \ if (!(expr)) { \ - dmnsn_error(DMNSN_SEVERITY_HIGH, (str)); \ + dmnsn_error((str)); \ } \ } while (0) #endif /** * @internal - * Called by dmnsn_error(); don't call directly. - * @param[in] severity The severity of the error. - * @param[in] func The name of the function where the error originated. - * @param[in] file The file where the error originated. - * @param[in] line The line number where the error originated. - * @param[in] str A string describing the error. - */ -void dmnsn_report_error(dmnsn_severity severity, - const char *func, const char *file, unsigned int line, - const char *str); - -/** - * Get the library resilience, thread-safely. - * @return The error severity considered fatal. + * Called by dmnsn_warning() and dmnsn_error(); don't call directly. + * @param[in] die Whether the error is fatal. + * @param[in] func The name of the function where the error originated. + * @param[in] file The file where the error originated. + * @param[in] line The line number where the error originated. + * @param[in] str A string describing the error. */ -dmnsn_severity dmnsn_get_resilience(void); +void dmnsn_report_error(bool die, const char *func, const char *file, + unsigned int line, const char *str); /** - * Set the library resilience, thread-safely. - * @param[in] resilience The new minimum severity that will cause a fatal - * error. + * Treat warnings as errors. + * @param[in] always_die Whether to die on warnings. */ -void dmnsn_set_resilience(dmnsn_severity resilience); +void dmnsn_die_on_warnings(bool always_die); /** * Fatal error callback type. This function should never return. -- cgit v1.2.3