@@ -51,6 +51,7 @@ static mbed_error_ctx first_error_ctx = {0};
51
51
static mbed_error_ctx last_error_ctx = {0 };
52
52
static mbed_error_hook_t error_hook = NULL ;
53
53
static void print_error_report (mbed_error_ctx * ctx , const char * );
54
+ static mbed_error_status_t handle_error (mbed_error_status_t error_status , unsigned int error_value , const char * filename , int line_number );
54
55
55
56
//Helper function to halt the system
56
57
static void mbed_halt_system (void )
@@ -72,20 +73,23 @@ WEAK void error(const char* format, ...) {
72
73
if (error_in_progress ) {
73
74
return ;
74
75
}
76
+
77
+ //Call handle_error/print_error_report permanently setting error_in_progress flag
78
+ handle_error (MBED_ERROR_UNKNOWN , 0 , NULL , 0 );
79
+ print_error_report (& last_error_ctx , "Fatal Run-time error" );
75
80
error_in_progress = 1 ;
76
81
77
82
#ifndef NDEBUG
78
83
va_list arg ;
79
84
va_start (arg , format );
80
85
mbed_error_vfprintf (format , arg );
81
- MBED_ERROR (MBED_ERROR_UNKNOWN , "Fatal Run-time Error" );
82
86
va_end (arg );
83
87
#endif
84
88
exit (1 );
85
89
}
86
90
87
91
//Set an error status with the error handling system
88
- mbed_error_status_t handle_error (mbed_error_status_t error_status , const char * error_msg , unsigned int error_value , const char * filename , int line_number )
92
+ static mbed_error_status_t handle_error (mbed_error_status_t error_status , unsigned int error_value , const char * filename , int line_number )
89
93
{
90
94
mbed_error_ctx current_error_ctx ;
91
95
@@ -182,14 +186,14 @@ int mbed_get_error_count(void)
182
186
//Sets a fatal error
183
187
mbed_error_status_t mbed_warning (mbed_error_status_t error_status , const char * error_msg , unsigned int error_value , const char * filename , int line_number )
184
188
{
185
- return handle_error (error_status , error_msg , error_value , filename , line_number );
189
+ return handle_error (error_status , error_value , filename , line_number );
186
190
}
187
191
188
192
//Sets a fatal error
189
193
WEAK mbed_error_status_t mbed_error (mbed_error_status_t error_status , const char * error_msg , unsigned int error_value , const char * filename , int line_number )
190
194
{
191
195
//set the error reported and then halt the system
192
- if ( MBED_SUCCESS != handle_error (error_status , error_msg , error_value , filename , line_number ) )
196
+ if ( MBED_SUCCESS != handle_error (error_status , error_value , filename , line_number ) )
193
197
return MBED_ERROR_FAILED_OPERATION ;
194
198
195
199
//On fatal errors print the error context/report
@@ -421,7 +425,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
421
425
#endif //TARGET_CORTEX_M
422
426
}
423
427
424
- mbed_error_printf ("\n-- MbedOS Error Info --" );
428
+ mbed_error_printf ("\n-- MbedOS Error Info --\n " );
425
429
}
426
430
427
431
0 commit comments