Function: icalendar-format-error

icalendar-format-error is a byte-compiled function defined in icalendar.el.gz.

Signature

(icalendar-format-error &rest ERROR-PLIST &key (MESSAGE "Unknown error") SEVERITY BUFFER POSITION &allow-other-keys)

Documentation

Format iCalendar error data to a string.

MESSAGE should be a string; it defaults to "Unknown error". BUFFER should be a buffer; POSITION should be a position in BUFFER. SEVERITY can be 0 for debug information, or 1 for a warning; otherwise a genuine error is reported.

The returned error message looks like

(LEVEL)BUFFER:POSITION: MESSAGE
DEBUG-INFO...

where LEVEL is derived from SEVERITY. DEBUG-INFO contains any additional data in ERROR-PLIST, if icalendar-debug-level is
0. icalendar-error-regexp matches the fields in such messages.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar.el.gz
(cl-defun ical:format-error (&rest error-plist
                             &key (message "Unknown error")
                                  severity
                                  buffer
                                  position
                                  &allow-other-keys)
  "Format iCalendar error data to a string.

MESSAGE should be a string; it defaults to \"Unknown error\".
BUFFER should be a buffer; POSITION should be a position in BUFFER.
SEVERITY can be 0 for debug information, or 1 for a warning; otherwise
a genuine error is reported.

The returned error message looks like

(LEVEL)BUFFER:POSITION: MESSAGE
DEBUG-INFO...

where LEVEL is derived from SEVERITY.  DEBUG-INFO contains any additional
data in ERROR-PLIST, if `icalendar-debug-level' is
0. `icalendar-error-regexp' matches the fields in such messages."
  (let ((name (copy-sequence (buffer-name buffer)))
        (pos (if (integer-or-marker-p position)
                 (format "%d" position)
               ""))
        (level (cond ((eq severity 0) "INFO")
                     ((eq severity 1) "WARNING")
                     (t "ERROR")))
        (debug-info (if (not (= 0 icalendar-debug-level))
                        ""
                      (mapconcat ;; (:key val...) => "Key: val\n..."
                       (lambda (val)
                         (if (keywordp val)
                             (capitalize (substring (symbol-name val) 1))
                           (format ": %s\n" val)))
                       error-plist))))
    ;; Make sure buffer name doesn't take too much space:
    (when (< 8 (length name))
      (if (equal " *UNFOLDED:" (substring name 0 11))
          (put-text-property 0 11 'display "..." name)
        (put-text-property 9 (length name) 'display "..." name)))
    (format "(%s)%s:%s: %s\n%s" level name pos message debug-info)))