Skip to content

Commit 845655b

Browse files
committed
Add case MBED_ERROR_CODE_ASSERTION_FAILED, fix names, pass expr to mbed_error
1 parent a2f3c59 commit 845655b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

platform/mbed_assert.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ void mbed_assert_internal(const char *expr, const char *file, int line)
2424
{
2525
core_util_critical_section_enter();
2626

27-
const char error_description[] = "Mbed assertation failed ";
28-
unsigned error_message_length = strlen(error_description) + strlen(expr) + 1;
29-
char error_message[error_message_length];
30-
snprintf(error_message, error_message_length, "%s%s", error_description, expr);
31-
32-
mbed_error(MBED_ERROR_ASSERTATION_FAILED, error_message, 0, file, line);
27+
mbed_error(MBED_ERROR_ASSERTION_FAILED, expr, 0, file, line);
3328
}
29+

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, ", ctx->error_value);
354+
break;
355+
352356
default:
353357
//Nothing to do here, just print the error info down
354358
break;

platform/mbed_error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ typedef enum _mbed_error_code {
780780
MBED_DEFINE_SYSTEM_ERROR(BLE_NO_FRAME_INITIALIZED, 65), /* 321 BLE No frame initialized */
781781
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_CREATION_FAILED, 66), /* 322 BLE Backend creation failed */
782782
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_NOT_INITIALIZED, 67), /* 323 BLE Backend not initialized */
783-
MBED_DEFINE_SYSTEM_ERROR(ASSERTATION_FAILED, 68), /* 324 Assertation Failed */
783+
MBED_DEFINE_SYSTEM_ERROR(ASSERTION_FAILED, 68), /* 324 Assertion Failed */
784784

785785
//Everytime you add a new system error code, you must update
786786
//Error documentation under Handbook to capture the info on

0 commit comments

Comments
 (0)