diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index b1922a04..d8e9edc1 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -462,7 +462,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif } @@ -624,7 +624,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif } #endif @@ -663,7 +663,7 @@ namespace etl this->set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif } #endif @@ -811,7 +811,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif } @@ -843,7 +843,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif } #endif @@ -951,7 +951,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif } @@ -987,7 +987,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif return to_iterator(position);; @@ -1002,7 +1002,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif } @@ -1028,7 +1028,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif } @@ -1073,7 +1073,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif return position_; @@ -1088,7 +1088,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif } @@ -1118,7 +1118,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif #endif } @@ -1157,7 +1157,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif } #endif @@ -1190,7 +1190,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif } #endif @@ -1617,7 +1617,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif } #endif @@ -1649,7 +1649,7 @@ namespace etl set_truncated(true); #if ETL_HAS_ERROR_ON_STRING_TRUNCATION - ETL_ALWAYS_ASSERT(ETL_ERROR(string_truncation)); + ETL_ASSERT_FAIL(ETL_ERROR(string_truncation)); #endif } #endif diff --git a/include/etl/error_handler.h b/include/etl/error_handler.h index fc85539f..d2d349ff 100644 --- a/include/etl/error_handler.h +++ b/include/etl/error_handler.h @@ -268,51 +268,58 @@ namespace etl ///\ingroup error_handler //*************************************************************************** #if defined(ETL_NO_CHECKS) - #define ETL_ASSERT(b, e) // Does nothing. - #define ETL_ASSERT_AND_RETURN(b, e) // Does nothing. - #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) // Does nothing. - #define ETL_ALWAYS_ASSERT(e) // Does nothing. - #define ETL_ALWAYS_ASSERT_AND_RETURN(e) // Does nothing. - #define ETL_ALWAYS_ASSERT_AND_RETURN_VALUE(e, v) // Does nothing. + #define ETL_ASSERT(b, e) // Does nothing. + #define ETL_ASSERT_AND_RETURN(b, e) // Does nothing. + #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) // Does nothing. + + #define ETL_ASSERT_FAIL(e) // Does nothing. + #define ETL_ASSERT_FAIL_AND_RETURN(e) // Does nothing. + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) // Does nothing. #elif ETL_USING_EXCEPTIONS #if defined(ETL_LOG_ERRORS) - #define ETL_ASSERT(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} // If the condition fails, calls the error handler then throws an exception. - #define ETL_ASSERT_AND_RETURN(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} // If the condition fails, calls the error handler then throws an exception. - #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} // If the condition fails, calls the error handler then throws an exception. - #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception. - #define ETL_ALWAYS_ASSERT_AND_RETURN(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception. - #define ETL_ALWAYS_ASSERT_AND_RETURN_VALUE(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception. + #define ETL_ASSERT(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} // If the condition fails, calls the error handler then throws an exception. + #define ETL_ASSERT_AND_RETURN(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return;}} // If the condition fails, calls the error handler then throws an exception. + #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {if (!(b)) {etl::error_handler::error((e)); throw((e)); return(v);}} // If the condition fails, calls the error handler then throws an exception. + + #define ETL_ASSERT_FAIL(e) {etl::error_handler::error((e)); throw((e));} // Calls the error handler then throws an exception. + #define ETL_ASSERT_FAIL_AND_RETURN(e) {etl::error_handler::error((e)); throw((e)); return;} // Calls the error handler then throws an exception. + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e) {etl::error_handler::error((e)); throw((e)); return(v);} // Calls the error handler then throws an exception. #else - #define ETL_ASSERT(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception. - #define ETL_ASSERT_AND_RETURN(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception. - #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception. - #define ETL_ALWAYS_ASSERT(e) {throw((e));} // Throws an exception. - #define ETL_ALWAYS_ASSERT_AND_RETURN(e) {throw((e));} // Throws an exception. - #define ETL_ALWAYS_ASSERT_AND_RETURN_VALUE(e, v) {throw((e));} // Throws an exception. + #define ETL_ASSERT(b, e) {if (!(b)) {throw((e));}} // If the condition fails, throws an exception. + #define ETL_ASSERT_AND_RETURN(b, e) {if (!(b)) {throw((e)); return;}} // If the condition fails, throws an exception. + #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {if (!(b)) {throw((e)); return(v);}} // If the condition fails, throws an exception. + + #define ETL_ASSERT_FAIL(e) {throw((e));} // Throws an exception. + #define ETL_ASSERT_FAIL_AND_RETURN(e) {throw((e)); return;} // Throws an exception. + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {throw((e)); return(v);} // Throws an exception. + #endif #else #if defined(ETL_LOG_ERRORS) #define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} // If the condition fails, calls the error handler #define ETL_ASSERT_AND_RETURN(b, e) {if(!(b)) {etl::error_handler::error((e)); return;}} // If the condition fails, calls the error handler and return #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {if(!(b)) {etl::error_handler::error((e)); return (v);}} // If the condition fails, calls the error handler and return a value - #define ETL_ALWAYS_ASSERT(e) {etl::error_handler::error((e));} // Calls the error handler - #define ETL_ALWAYS_ASSERT_AND_RETURN(e) {etl::error_handler::error((e)); return;} // Calls the error handler and return - #define ETL_ALWAYS_ASSERT_AND_RETURN_VALUE(e, v) {etl::error_handler::error((e)); return (v);} // Calls the error handler and return a value + + #define ETL_ASSERT_FAIL(e) {etl::error_handler::error((e));} // Calls the error handler + #define ETL_ASSERT_FAIL_AND_RETURN(e) {etl::error_handler::error((e)); return;} // Calls the error handler and return + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {etl::error_handler::error((e)); return (v);} // Calls the error handler and return a value #else #if ETL_IS_DEBUG_BUILD - #define ETL_ASSERT(b, e) assert((b)) // If the condition fails, asserts. - #define ETL_ASSERT_AND_RETURN(b, e) assert((b)) // If the condition fails, asserts. - #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) assert((b)) // If the condition fails, asserts. - #define ETL_ALWAYS_ASSERT(e) assert(false) // Asserts. - #define ETL_ALWAYS_ASSERT_AND_RETURN(e) assert(false) // Asserts. - #define ETL_ALWAYS_ASSERT_AND_RETURN_VALUE(e, v) assert(false) // Asserts. + #define ETL_ASSERT(b, e) assert((b)) // If the condition fails, asserts. + #define ETL_ASSERT_AND_RETURN(b, e) {assert((b)); return;} // If the condition fails, asserts. + #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {assert((b)); return(v);} // If the condition fails, asserts. + + #define ETL_ASSERT_FAIL(e) assert(false) // Asserts. + #define ETL_ASSERT_FAIL_AND_RETURN(e) {assert(false); return;} // Asserts. + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {assert(false); return(v);} // Asserts. #else - #define ETL_ASSERT(b, e) // Does nothing. - #define ETL_ASSERT_AND_RETURN(b, e) {if (!(b)) return;} // Returns. - #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {if (!(b)) return(v);} // Returns a value. - #define ETL_ALWAYS_ASSERT(e) // Does nothing. - #define ETL_ALWAYS_ASSERT_AND_RETURN(e) {return;} // Returns. - #define ETL_ALWAYS_ASSERT_AND_RETURN_VALUE(e, v) {return(v);} // Returns a value. + #define ETL_ASSERT(b, e) // Does nothing. + #define ETL_ASSERT_AND_RETURN(b, e) {if (!(b)) return;} // Returns. + #define ETL_ASSERT_AND_RETURN_VALUE(b, e, v) {if (!(b)) return(v);} // Returns a value. + + #define ETL_ASSERT_FAIL(e) // Does nothing. + #define ETL_ASSERT_FAIL_AND_RETURN(e) {return;} // Returns. + #define ETL_ASSERT_FAIL_AND_RETURN_VALUE(e, v) {return(v);} // Returns a value. #endif #endif #endif diff --git a/include/etl/message_router_registry.h b/include/etl/message_router_registry.h index c9245ad1..b96908c4 100644 --- a/include/etl/message_router_registry.h +++ b/include/etl/message_router_registry.h @@ -361,7 +361,7 @@ namespace etl } else { - ETL_ALWAYS_ASSERT(ETL_ERROR(etl::message_router_registry_full)); + ETL_ASSERT_FAIL(ETL_ERROR(etl::message_router_registry_full)); } }