Skip to content

Commit ce7e61e

Browse files
author
Cruz Monrreal
authored
Merge pull request #8255 from MateuszMaz/refactoring_mbed_assert
Change behaviour of mbed_asert to use mbed_error instead of mbed_die
2 parents 461d59a + e6ae3d2 commit ce7e61e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

platform/mbed_assert.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
17+
#include <string.h>
1618
#include "platform/mbed_assert.h"
17-
#include "device.h"
1819

19-
#include "platform/mbed_interface.h"
2020
#include "platform/mbed_critical.h"
21+
#include "platform/mbed_error.h"
2122

2223
void mbed_assert_internal(const char *expr, const char *file, int line)
2324
{
2425
core_util_critical_section_enter();
25-
mbed_error_printf("mbed assertation failed: %s, file: %s, line %d \n", expr, file, line);
26-
mbed_die();
26+
mbed_error(MBED_ERROR_ASSERTION_FAILED, expr, 0, file, line);
2727
}
28+

platform/mbed_error.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
349349
mbed_error_printf("MessageQueue: 0x%X, ", ctx->error_value);
350350
break;
351351

352+
case MBED_ERROR_CODE_ASSERTION_FAILED:
353+
mbed_error_printf("Assertion failed: ");
354+
break;
355+
352356
default:
353357
//Nothing to do here, just print the error info down
354358
break;

platform/mbed_error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,8 @@ typedef enum _mbed_error_code {
783783
MBED_DEFINE_SYSTEM_ERROR(BLE_NO_FRAME_INITIALIZED, 65), /* 321 BLE No frame initialized */
784784
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_CREATION_FAILED, 66), /* 322 BLE Backend creation failed */
785785
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_NOT_INITIALIZED, 67), /* 323 BLE Backend not initialized */
786-
786+
MBED_DEFINE_SYSTEM_ERROR(ASSERTION_FAILED, 68), /* 324 Assertion Failed */
787+
787788
//Everytime you add a new system error code, you must update
788789
//Error documentation under Handbook to capture the info on
789790
//the new error status/codes

0 commit comments

Comments
 (0)