Skip to content

Commit 5953510

Browse files
yuhan0bbatsov
authored andcommitted
Refactor error-matching regexes
Merge with cider-clojure-unexpected-error into a single regex, Match :read-eval-result and :print-eval-result error phases
1 parent 751f170 commit 5953510

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

cider-eval.el

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -576,22 +576,15 @@ It delegates the actual error content to the eval or op handler."
576576

577577
(defconst cider-clojure-1.10-error
578578
`(sequence
579-
"Syntax error "
580-
(minimal-match (zero-or-more anything))
581-
(or "compiling "
582-
"macroexpanding "
583-
"reading source ")
584-
(minimal-match (zero-or-more anything))
585-
,cider-clojure-1.10--location))
586-
587-
(defconst cider-clojure-unexpected-error
588-
`(sequence
589-
"Unexpected error (" (minimal-match (one-or-more anything)) ") "
590-
(or "compiling "
591-
"macroexpanding "
592-
"reading source ")
593-
(minimal-match (one-or-more anything))
594-
,cider-clojure-1.10--location))
579+
(or "Syntax error reading source " ; phase = :read-source
580+
(sequence
581+
(or "Syntax error " "Unexpected error ")
582+
(minimal-match (zero-or-more anything)) ; optional class, eg. (ClassCastException)
583+
(or "macroexpanding " ; phase = :macro-syntax-check / :macroexpansion
584+
"compiling ") ; phase = :compile-syntax-check / :compilation
585+
(minimal-match (zero-or-more anything)))) ; optional symbol, eg. foo/bar
586+
,cider-clojure-1.10--location)
587+
"Regexp matching error messages triggered in compilation / read / print phases.")
595588

596589
(defconst cider-clojure-warning
597590
`(sequence
@@ -608,8 +601,7 @@ It delegates the actual error content to the eval or op handler."
608601
(defconst cider-clojure-compilation-regexp
609602
(rx-to-string
610603
`(seq bol (or ,cider-clojure-warning
611-
,cider-clojure-1.10-error
612-
,cider-clojure-unexpected-error))
604+
,cider-clojure-1.10-error))
613605
'nogroup)
614606
"A few example values that will match:
615607
\"Reflection warning, /tmp/foo/src/foo/core.clj:14:1 - \"
@@ -620,8 +612,7 @@ lol in this context, compiling:(/foo/core.clj:10:1)\"
620612

621613
(defconst cider-clojure-compilation-error-regexp
622614
(rx-to-string
623-
`(seq bol (or ,cider-clojure-1.10-error
624-
,cider-clojure-unexpected-error))
615+
`(seq bol ,cider-clojure-1.10-error)
625616
'nogroup)
626617
"Like `cider-clojure-compilation-regexp',
627618
but excluding warnings such as reflection warnings.
@@ -634,8 +625,10 @@ lol in this context, compiling:(/foo/core.clj:10:1)\"
634625

635626
(defconst cider--clojure-execution-error-regexp
636627
`(sequence
637-
"Execution error "
638-
(minimal-match (zero-or-more anything))
628+
(or "Error reading eval result " ; phase = :read-eval-result
629+
"Error printing return value " ; phase = :print-eval-result
630+
"Execution error ") ; phase = :execution
631+
(minimal-match (zero-or-more anything)) ; optional class, eg. (ArithmeticException)
639632
,cider-clojure-1.10--location))
640633

641634
(defconst cider--clojure-spec-execution-error-regexp

0 commit comments

Comments
 (0)