Function: error-message-string

error-message-string is a function defined in print.c.

Signature

(error-message-string OBJ)

Documentation

Convert an error value (ERROR-SYMBOL . DATA) to an error message.

See Info anchor (elisp)Definition of signal for some details on how this error message is constructed.

View in manual

Probably introduced at or before Emacs version 19.31.

Source Code

// Defined in /usr/src/emacs/src/print.c
{
  /* If OBJ is (error STRING), just return STRING.
     That is not only faster, it also avoids the need to allocate
     space here when the error is due to memory full.  */
  if (CONSP (obj) && EQ (XCAR (obj), Qerror)
      && CONSP (XCDR (obj))
      && STRINGP (XCAR (XCDR (obj)))
      && NILP (XCDR (XCDR (obj))))
    return XCAR (XCDR (obj));

  /* print_error_message can throw after producing some output, in which
     case we need to ensure the buffer is cleared again (bug#78842).  */
  specpdl_ref count = SPECPDL_INDEX ();
  record_unwind_current_buffer ();
  record_unwind_protect_void (erase_prin1_to_string_buffer);
  print_error_message (obj, Vprin1_to_string_buffer, 0, Qnil);

  set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
  return unbind_to (count, Fbuffer_string ());
}