<commit_before>;;;;
;; Condition
;;;;


(define-condition too-expendsive (error)
  ((price :initarg :price
          :reader price))
  (:report (lambda (condition stream)
             (format stream "At ~A Euro~:P that's too expensive."
                     (price condition)))))

(defparameter *price* (make-condition 'too-expendsive :price 49))

(price *price*)

(format nil "~A" *price*)

;; signal does nothing and just returns nil
(list (signal (make-condition 'too-expendsive)) :foo)
(list (signal (make-condition 'error)) :bar)

;; warn
(list (warn (make-condition 'warning)) :baz)

(handler-case
    (signal *price*)
  (error ()
    "ok, it's a signal"))

(handler-case
    (error *price*)
  (error ()
    "ok, it's an error"))

;; cerror takes a format-control string, `M-.' to see definition
;;(cerror "Proceed." *price*)
<commit_msg>handler-case<commit_after>;;;;
;; Condition
;;;;


(define-condition too-expensive (error)
  ((price :initarg :price
          :reader price))
  (:report (lambda (condition stream)
             (format stream "At ~A Euro~:P that's too expensive."
                     (price condition)))))

(defparameter *price* (make-condition 'too-expensive :price 49))

(price *price*)

(format nil "~A" *price*)

;; signal does nothing and just returns nil
(list (signal (make-condition 'too-expensive)) :foo)
(list (signal (make-condition 'error)) :bar)

;; warn
(list (warn (make-condition 'warning)) :baz)

(handler-case
    (signal *price*)
  (error ()
    "ok, it's a signal"))

(handler-case
    (error *price*)
  (error ()
    "ok, it's an error"))

;; cerror takes a format-control string, `M-.' to see definition
;;(cerror "Proceed." *price*)


(defun access-condition (condition)
	(handler-case (signal condition)
		(warning () "Lots of smoke, but no fire.")
		((or arithmetic-error control-error stream-error) (condition)
			(format nil "~S looks especially bad." condition))
		(serious-condition (condition)
			(format nil "~S looks serious." condition))
		(condition () "Hardly worth mentioniong.")))

(access-condition (make-condition 'stream-error :stream *terminal-io*))

(define-condition random-condition (condition)
	()
	(:report (lambda (condition stream)
						 (declare (ignore condition))
						 (princ "Yow" stream))))

(access-condition (make-condition 'random-condition))

(access-condition (make-condition 'serious-condition :bar #x1122))

(defun foo (a b)
	(handler-case (/ a b)
		(division-by-zero (condition) (format t "~A~%" condition))))
{'fraction_non_alphanumeric': 0.16633346661335466, 'fraction_numerical': 0.003198720511795282, 'mean_word_length': 3.793103448275862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1839349', 'n_tokens_mistral': 841, 'n_tokens_neox': 771, 'n_words': 250}