|
773 | 773 |
|
774 | 774 | (def ^:private re-exception-start |
775 | 775 | "The start of an exception, possibly the outermost exception." |
776 | | - #"(Caused by: )?(\w+(\.\w+)*): (.*)" |
777 | | - ; Group 2 - exception name |
778 | | - ; Group 4 - exception message |
779 | | - ) |
| 776 | + #"(?ix) |
| 777 | + (?:caused \s by: \s)? |
| 778 | + (\w+(?:\.\w+)*) # Group 1 - exception name |
| 779 | + (?: |
| 780 | + : \s |
| 781 | + (.*))? # Group 2 - exception message (or nil)") |
780 | 782 |
|
781 | 783 | (def ^:private re-stack-frame |
782 | 784 | ;; Sometimes the file name and line number are replaced with "Unknown source" |
783 | | - #"\s+at ([a-zA-Z_.$\d<>]+)\(((.+):(\d+))?.*\).*" |
784 | | - ; Group 1 - class and method name |
785 | | - ; Group 3 - file name (or nil) |
786 | | - ; Group 4 - line number (or nil) |
787 | | - ) |
| 785 | + #"(?ix) |
| 786 | + \s+ |
| 787 | + at |
| 788 | + \s |
| 789 | + (?: |
| 790 | + [a-z.]+/)? # java.base/ prefix |
| 791 | + ([a-z_.$\d<>]+) # Group 1 - class and method name |
| 792 | + \( |
| 793 | + (?: |
| 794 | + (?: |
| 795 | + (.+) # Group 2 - file name |
| 796 | + : |
| 797 | + (\d+) # Group 3 - line number |
| 798 | + )? |
| 799 | + .* # match \"Native Method\" if no file/line |
| 800 | + ) |
| 801 | + \) |
| 802 | + .* # Extra text (older JRE JAR and version data?) |
| 803 | + ") |
| 804 | + |
| 805 | +(def ^:private re-more-frames |
| 806 | + #"(?ix) |
| 807 | + \s+ |
| 808 | + \Q...\E |
| 809 | + \s+ |
| 810 | + \d+ |
| 811 | + \s+ |
| 812 | + (?:more|\Qcommon frames omitted\E)") |
788 | 813 |
|
789 | 814 | (defn- add-message-text |
790 | 815 | [exceptions line] |
|
815 | 840 | (defn parse-exception |
816 | 841 | "Given a chunk of text from an exception report (as with `.printStackTrace`), attempts to |
817 | 842 | piece together the same information provided by [[analyze-exception]]. The result |
818 | | - is ready to pass to [[write-exception*]]. |
| 843 | + is ready to pass to [[format-exception*]]. |
819 | 844 |
|
820 | 845 | This code does not attempt to recreate properties associated with the exceptions; in most |
821 | 846 | exception's cases, this is not necessarily written to the output. For clojure.lang.ExceptionInfo, |
|
844 | 869 | (condp = state |
845 | 870 |
|
846 | 871 | :start |
847 | | - (let [[_ _ exception-class-name _ exception-message] (re-matches re-exception-start line)] |
| 872 | + (let [[_ exception-class-name exception-message] (re-matches re-exception-start line)] |
848 | 873 | (when-not exception-class-name |
849 | 874 | (throw (ex-info "Unable to parse start of exception." |
850 | 875 | {:line line |
|
869 | 894 | stack-trace-batch)) |
870 | 895 |
|
871 | 896 | :stack-frame |
872 | | - (let [[_ class-and-method _ file-name line-number] (re-matches re-stack-frame line)] |
| 897 | + (let [[_ class-and-method file-name line-number] (re-matches re-stack-frame line)] |
873 | 898 | (if class-and-method |
874 | 899 | (recur :stack-frame |
875 | 900 | more-lines |
|
888 | 913 | []))) |
889 | 914 |
|
890 | 915 | :skip-more-line |
891 | | - (if (re-matches #"\s+\.\.\. \d+ (more|common frames omitted)" line) |
| 916 | + (if (re-matches re-more-frames line) |
892 | 917 | (recur :start more-lines |
893 | 918 | exceptions stack-trace stack-trace-batch) |
894 | 919 | (recur :start lines |
|
0 commit comments