@jsreport/jsreport-cli 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/lib/utils/error.js +35 -16
- package/package.json +3 -3
package/README.md
CHANGED
package/lib/utils/error.js
CHANGED
|
@@ -70,7 +70,6 @@ function getErrors (err) {
|
|
|
70
70
|
|
|
71
71
|
function getErrorMessages (err) {
|
|
72
72
|
const errors = getErrors(err)
|
|
73
|
-
let count = errors.length
|
|
74
73
|
let cleanState = false
|
|
75
74
|
const messages = []
|
|
76
75
|
const stacks = []
|
|
@@ -85,34 +84,26 @@ function getErrorMessages (err) {
|
|
|
85
84
|
|
|
86
85
|
customProps = JSON.stringify(customProps)
|
|
87
86
|
|
|
88
|
-
|
|
89
|
-
messages.push(`${formatError(error)}`)
|
|
90
|
-
} else {
|
|
91
|
-
messages.push(`${formatError(error)} (${count})`)
|
|
92
|
-
}
|
|
87
|
+
messages.push(`${formatError(error)}`)
|
|
93
88
|
|
|
94
89
|
if (customProps === '{}') {
|
|
95
90
|
customProps = ''
|
|
96
91
|
}
|
|
97
92
|
|
|
98
93
|
if (currentStack !== '') {
|
|
99
|
-
const causedBy = `caused by error (${count}):`
|
|
100
|
-
|
|
101
94
|
if (customProps !== '') {
|
|
102
|
-
stacks.push(
|
|
95
|
+
stacks.push(`-> meta = ${customProps}\n-> stack\n${currentStack}`)
|
|
103
96
|
} else {
|
|
104
|
-
stacks.push(
|
|
97
|
+
stacks.push(`-> stack\n${currentStack}`)
|
|
105
98
|
}
|
|
106
99
|
}
|
|
107
|
-
|
|
108
|
-
count--
|
|
109
100
|
})
|
|
110
101
|
|
|
111
102
|
if (!cleanState && stacks.length > 0) {
|
|
112
|
-
messages
|
|
103
|
+
return [messages, stacks]
|
|
113
104
|
}
|
|
114
105
|
|
|
115
|
-
return messages
|
|
106
|
+
return [messages, []]
|
|
116
107
|
}
|
|
117
108
|
|
|
118
109
|
function getSimpleProperties (obj) {
|
|
@@ -138,9 +129,37 @@ function getSimpleProperties (obj) {
|
|
|
138
129
|
}
|
|
139
130
|
|
|
140
131
|
function printError (err, logger) {
|
|
141
|
-
const messages = getErrorMessages(err)
|
|
132
|
+
const [messages, stacks] = getErrorMessages(err)
|
|
133
|
+
|
|
134
|
+
for (let idx = 0; idx < messages.length; idx++) {
|
|
135
|
+
messages[idx] += ` (${messages.length - idx})`
|
|
136
|
+
|
|
137
|
+
if (idx > 0) {
|
|
138
|
+
messages[idx] = lowerCaseFirstLetter(messages[idx])
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let errorLog = messages.join('\n(because) ')
|
|
143
|
+
|
|
144
|
+
if (stacks.length > 0) {
|
|
145
|
+
const reversedStacks = [...stacks].reverse()
|
|
146
|
+
|
|
147
|
+
for (let idx = 0; idx < reversedStacks.length; idx++) {
|
|
148
|
+
reversedStacks[idx] = `-- error (${idx + 1}) --\n${reversedStacks[idx]}`
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
errorLog += `\n\n${reversedStacks.join('\nwrapped by:\n')}`
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
logger.error(errorLog)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function lowerCaseFirstLetter (str) {
|
|
158
|
+
if (str === '' || typeof str !== 'string') {
|
|
159
|
+
return str
|
|
160
|
+
}
|
|
142
161
|
|
|
143
|
-
|
|
162
|
+
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
144
163
|
}
|
|
145
164
|
|
|
146
165
|
module.exports.printError = printError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsreport/jsreport-cli",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "Command line interface for jsreport",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jsreport",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@jsreport/jsreport-authentication": "3.3.2",
|
|
74
|
-
"@jsreport/jsreport-core": "3.
|
|
75
|
-
"@jsreport/jsreport-express": "3.
|
|
74
|
+
"@jsreport/jsreport-core": "3.9.0",
|
|
75
|
+
"@jsreport/jsreport-express": "3.5.0",
|
|
76
76
|
"@jsreport/jsreport-fs-store": "3.2.3",
|
|
77
77
|
"@jsreport/jsreport-handlebars": "3.2.1",
|
|
78
78
|
"cross-env": "5.2.1",
|