cancel
Showing results for 
Search instead for 
Did you mean: 

Request for enhancement. Error_Handler in main.c generated by Cube 4.17.0

Posted on October 12, 2016 at 22:51

In the latest version of Cube (4.17.0), when main.c is generated, you get a function called Error_Handler() that is called by the HAL functions anytime the return code is not HAL_OK. Error_Handler just goes into a tight loop, leaving you scratching your head as to why your program isn't working.

This is somewhat better than the previous construct, but in my small program, this function is called in 51 places. It would be useful if Error_Handler had some parameters so you could print out __FILE__ and __LINE__ so you could at least print out some sort of message that could lead you to a solution. That would mean using some sort of a macro along the lines of assert_param.

As it is now, the only thing that Error_Handler can be used for is some sort of printf(''blammo I blew up\n''); or as a space to put a breakpoint for when you are debugging.

Thanks,

Andrei from The Great White North
10 REPLIES 10
Posted on January 22, 2018 at 23:04

Would definitely agree that the __FILE__ and __LINE__ is a critical addition. There also needs to be USER scope around the calling points so things can get remediated.

The user really needs to consider what to do at each of these points to try and recover/retry the situation. This would be particularly difficult from callbacks, in which case the logic of all the code needs to be reviewed so as to avoid these conditions.

Shipping code with these traps in will be a technical support disaster.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..