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