diff --git a/include/etl/error_handler.h b/include/etl/error_handler.h index 425f68ef..2fb10011 100644 --- a/include/etl/error_handler.h +++ b/include/etl/error_handler.h @@ -397,15 +397,23 @@ namespace etl //************************************* #if defined(ETL_VERBOSE_ERRORS) - #define ETL_ERROR(e) (e(__FILE__, __LINE__)) // Make an exception with the file name and line number. - #define ETL_ERROR_WITH_VALUE(e, v) (e(__FILE__, __LINE__, (v))) // Make an exception with the file name, line number and value. - #define ETL_ERROR_TEXT(verbose_text, terse_text) (verbose_text) // Use the verbose text. - #define ETL_ERROR_GENERIC(text) (etl::exception((text),__FILE__, __LINE__)) // Make a generic exception with a message, file name and line number. + // include everything, file name, line number, verbose text + #define ETL_ERROR(e) (e(__FILE__, __LINE__)) + #define ETL_ERROR_WITH_VALUE(e, v) (e(__FILE__, __LINE__, (v))) + #define ETL_ERROR_TEXT(verbose_text, terse_text) (verbose_text) + #define ETL_ERROR_GENERIC(text) (etl::exception((text), __FILE__, __LINE__)) +#elif defined(ETL_MINIMAL_ERRORS) + // include nothing, no file name, no line number, no text + #define ETL_ERROR(e) (e("", -1)) + #define ETL_ERROR_WITH_VALUE(e, v) (e("", -1, (v))) + #define ETL_ERROR_TEXT(verbose_text, terse_text) ("") + #define ETL_ERROR_GENERIC(text) (etl::exception("", "", -1)) #else - #define ETL_ERROR(e) (e("", __LINE__)) // Make an exception with the line number. - #define ETL_ERROR_WITH_VALUE(e, v) (e("", __LINE__, (v))) // Make an exception with the file name, line number and value. - #define ETL_ERROR_TEXT(verbose_text, terse_text) (terse_text) // Use the terse text. - #define ETL_ERROR_GENERIC(text) (etl::exception((text),"", __LINE__)) // Make a generic exception with a message and line number. + // include only terse text, no file name, no line number + #define ETL_ERROR(e) (e("", -1)) + #define ETL_ERROR_WITH_VALUE(e, v) (e("", -1, (v))) + #define ETL_ERROR_TEXT(verbose_text, terse_text) (terse_text) + #define ETL_ERROR_GENERIC(text) (etl::exception((text),"", -1)) #endif #endif diff --git a/include/etl/exception.h b/include/etl/exception.h index 4323df78..c73fef1c 100644 --- a/include/etl/exception.h +++ b/include/etl/exception.h @@ -60,26 +60,27 @@ namespace etl typedef const char* string_type; typedef int numeric_type; - -#if defined(ETL_VERBOSE_ERRORS) + //************************************************************************* /// Constructor. //************************************************************************* - ETL_EXCEPTION_CONSTEXPR +#if defined(ETL_VERBOSE_ERRORS) + ETL_CONSTEXPR exception(string_type reason_, string_type file_, numeric_type line_) : reason_text(reason_), file_text(file_), line(line_) { } +#elif defined(ETL_MINIMAL_ERRORS) + ETL_CONSTEXPR + exception(string_type /*reason_*/, string_type /*file_*/, numeric_type /*line_*/) + { + } #else - //************************************************************************* - /// Constructor. - //************************************************************************* - ETL_EXCEPTION_CONSTEXPR - exception(string_type reason_, string_type /*file_*/, numeric_type line_) - : reason_text(reason_), - line(line_) + ETL_CONSTEXPR + exception(string_type reason_, string_type /*file_*/, numeric_type /*line_*/) + : reason_text(reason_) { } #endif @@ -94,7 +95,11 @@ namespace etl override #endif { +#if !defined(ETL_MINIMAL_ERRORS) return reason_text; +#else + return ""; +#endif } @@ -119,16 +124,23 @@ namespace etl ETL_CONSTEXPR numeric_type line_number() const { +#if defined(ETL_VERBOSE_ERRORS) return line; +#else + return -1; +#endif } private: - string_type reason_text; ///< The reason for the exception. +#if !defined(ETL_MINIMAL_ERRORS) + string_type reason_text; ///< The reason for the exception. +#endif + #if defined(ETL_VERBOSE_ERRORS) string_type file_text; ///< The file for the exception. -#endif numeric_type line; ///< The line for the exception. +#endif }; } diff --git a/include/etl/platform.h b/include/etl/platform.h index 62a5da60..116daeb4 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -83,6 +83,12 @@ SOFTWARE. #define ETL_IS_DEBUG_BUILD 0 #endif +//************************************* +// Do a validity check for error settings, only one is allowed. +#if defined(ETL_VERBOSE_ERRORS) && defined(ETL_MINIMAL_ERRORS) + #error "ETL_VERBOSE_ERRORS and ETL_MINIMAL_ERRORS are mutually exclusive" +#endif + //************************************* // Helper macros, so we don't have to use double negatives. // The ETL will use the STL, unless ETL_NO_STL is defined.