Mistake on this page?
Report an issue in GitHub or email us


Mbed OS provides an error function to output messages to STDIO at runtime when the system encounters a fatal error and the Application calling the error function will be terminated. Note that the error function outputs the error message in debug and develop builds only. In release builds, the error function does not generate any STDIO output, but the application is still terminated. mbed_error.h declares the error function.

Error function reference

Error example

The code below uses an error function to print a fatal error indicating an out-of-memory condition.

void *operator new(std::size_t count) {
    void *buffer = malloc(count);
    if (NULL == buffer) {
        error("Operator new out of memory\r\n");
    return buffer;
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.