1 | // Specification:
|
---|
2 | // https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/Throwable.html#printStackTrace()
|
---|
3 |
|
---|
4 | Prism.languages.javastacktrace = {
|
---|
5 |
|
---|
6 | // java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]
|
---|
7 | // Caused by: java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]
|
---|
8 | // Caused by: com.example.myproject.MyProjectServletException
|
---|
9 | // Caused by: MidLevelException: LowLevelException
|
---|
10 | // Suppressed: Resource$CloseFailException: Resource ID = 0
|
---|
11 | 'summary': {
|
---|
12 | pattern: /^([\t ]*)(?:(?:Caused by:|Suppressed:|Exception in thread "[^"]*")[\t ]+)?[\w$.]+(?::.*)?$/m,
|
---|
13 | lookbehind: true,
|
---|
14 | inside: {
|
---|
15 | 'keyword': {
|
---|
16 | pattern: /^([\t ]*)(?:(?:Caused by|Suppressed)(?=:)|Exception in thread)/m,
|
---|
17 | lookbehind: true
|
---|
18 | },
|
---|
19 |
|
---|
20 | // the current thread if the summary starts with 'Exception in thread'
|
---|
21 | 'string': {
|
---|
22 | pattern: /^(\s*)"[^"]*"/,
|
---|
23 | lookbehind: true
|
---|
24 | },
|
---|
25 | 'exceptions': {
|
---|
26 | pattern: /^(:?\s*)[\w$.]+(?=:|$)/,
|
---|
27 | lookbehind: true,
|
---|
28 | inside: {
|
---|
29 | 'class-name': /[\w$]+$/,
|
---|
30 | 'namespace': /\b[a-z]\w*\b/,
|
---|
31 | 'punctuation': /\./
|
---|
32 | }
|
---|
33 | },
|
---|
34 | 'message': {
|
---|
35 | pattern: /(:\s*)\S.*/,
|
---|
36 | lookbehind: true,
|
---|
37 | alias: 'string'
|
---|
38 | },
|
---|
39 | 'punctuation': /:/
|
---|
40 | }
|
---|
41 | },
|
---|
42 |
|
---|
43 | // at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
|
---|
44 | // at org.hsqldb.jdbc.Util.throwError(Unknown Source) here could be some notes
|
---|
45 | // at java.base/java.lang.Class.forName0(Native Method)
|
---|
46 | // at Util.<init>(Unknown Source)
|
---|
47 | // at com.foo.loader/foo@9.0/com.foo.Main.run(Main.java:101)
|
---|
48 | // at com.foo.loader//com.foo.bar.App.run(App.java:12)
|
---|
49 | // at acme@2.1/org.acme.Lib.test(Lib.java:80)
|
---|
50 | // at MyClass.mash(MyClass.java:9)
|
---|
51 | //
|
---|
52 | // More information:
|
---|
53 | // https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/StackTraceElement.html#toString()
|
---|
54 | //
|
---|
55 | // A valid Java module name is defined as:
|
---|
56 | // "A module name consists of one or more Java identifiers (§3.8) separated by "." tokens."
|
---|
57 | // https://docs.oracle.com/javase/specs/jls/se9/html/jls-6.html#jls-ModuleName
|
---|
58 | //
|
---|
59 | // A Java module version is defined by this class:
|
---|
60 | // https://docs.oracle.com/javase/9/docs/api/java/lang/module/ModuleDescriptor.Version.html
|
---|
61 | // This is the implementation of the `parse` method in JDK13:
|
---|
62 | // https://github.com/matcdac/jdk/blob/2305df71d1b7710266ae0956d73927a225132c0f/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java#L1108
|
---|
63 | // However, to keep this simple, a version will be matched by the pattern /@[\w$.+-]*/.
|
---|
64 | 'stack-frame': {
|
---|
65 | pattern: /^([\t ]*)at (?:[\w$./]|@[\w$.+-]*\/)+(?:<init>)?\([^()]*\)/m,
|
---|
66 | lookbehind: true,
|
---|
67 | inside: {
|
---|
68 | 'keyword': {
|
---|
69 | pattern: /^(\s*)at(?= )/,
|
---|
70 | lookbehind: true
|
---|
71 | },
|
---|
72 | 'source': [
|
---|
73 | // (Main.java:15)
|
---|
74 | // (Main.scala:15)
|
---|
75 | {
|
---|
76 | pattern: /(\()\w+\.\w+:\d+(?=\))/,
|
---|
77 | lookbehind: true,
|
---|
78 | inside: {
|
---|
79 | 'file': /^\w+\.\w+/,
|
---|
80 | 'punctuation': /:/,
|
---|
81 | 'line-number': {
|
---|
82 | pattern: /\b\d+\b/,
|
---|
83 | alias: 'number'
|
---|
84 | }
|
---|
85 | }
|
---|
86 | },
|
---|
87 | // (Unknown Source)
|
---|
88 | // (Native Method)
|
---|
89 | // (...something...)
|
---|
90 | {
|
---|
91 | pattern: /(\()[^()]*(?=\))/,
|
---|
92 | lookbehind: true,
|
---|
93 | inside: {
|
---|
94 | 'keyword': /^(?:Native Method|Unknown Source)$/
|
---|
95 | }
|
---|
96 | }
|
---|
97 | ],
|
---|
98 | 'class-name': /[\w$]+(?=\.(?:<init>|[\w$]+)\()/,
|
---|
99 | 'function': /(?:<init>|[\w$]+)(?=\()/,
|
---|
100 | 'class-loader': {
|
---|
101 | pattern: /(\s)[a-z]\w*(?:\.[a-z]\w*)*(?=\/[\w@$.]*\/)/,
|
---|
102 | lookbehind: true,
|
---|
103 | alias: 'namespace',
|
---|
104 | inside: {
|
---|
105 | 'punctuation': /\./
|
---|
106 | }
|
---|
107 | },
|
---|
108 | 'module': {
|
---|
109 | pattern: /([\s/])[a-z]\w*(?:\.[a-z]\w*)*(?:@[\w$.+-]*)?(?=\/)/,
|
---|
110 | lookbehind: true,
|
---|
111 | inside: {
|
---|
112 | 'version': {
|
---|
113 | pattern: /(@)[\s\S]+/,
|
---|
114 | lookbehind: true,
|
---|
115 | alias: 'number'
|
---|
116 | },
|
---|
117 | 'punctuation': /[@.]/
|
---|
118 | }
|
---|
119 | },
|
---|
120 | 'namespace': {
|
---|
121 | pattern: /(?:\b[a-z]\w*\.)+/,
|
---|
122 | inside: {
|
---|
123 | 'punctuation': /\./
|
---|
124 | }
|
---|
125 | },
|
---|
126 | 'punctuation': /[()/.]/
|
---|
127 | }
|
---|
128 | },
|
---|
129 |
|
---|
130 | // ... 32 more
|
---|
131 | // ... 32 common frames omitted
|
---|
132 | 'more': {
|
---|
133 | pattern: /^([\t ]*)\.{3} \d+ [a-z]+(?: [a-z]+)*/m,
|
---|
134 | lookbehind: true,
|
---|
135 | inside: {
|
---|
136 | 'punctuation': /\.{3}/,
|
---|
137 | 'number': /\d+/,
|
---|
138 | 'keyword': /\b[a-z]+(?: [a-z]+)*\b/
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 | };
|
---|