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.

Probably introduced at or before Emacs version 19.31.

Source Code

// Defined in /usr/src/emacs/src/print.c
{
  struct buffer *old = current_buffer;
  Lisp_Object value;

  /* 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 (obj, Vprin1_to_string_buffer, 0, Qnil);

  set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
  value = Fbuffer_string ();

  Ferase_buffer ();
  set_buffer_internal (old);

  return value;
}