@lvce-editor/json-rpc 5.5.0 → 6.0.0
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/dist/index.js +12 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -234,6 +234,17 @@ const getErrorType = prettyError => {
|
|
|
234
234
|
return undefined;
|
|
235
235
|
};
|
|
236
236
|
|
|
237
|
+
const isAlreadyStack = line => {
|
|
238
|
+
return line.trim().startsWith('at ');
|
|
239
|
+
};
|
|
240
|
+
const getStack = prettyError => {
|
|
241
|
+
const stackString = prettyError.stack || '';
|
|
242
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
243
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
244
|
+
return stackString.slice(newLineIndex + 1);
|
|
245
|
+
}
|
|
246
|
+
return stackString;
|
|
247
|
+
};
|
|
237
248
|
const getErrorProperty = (error, prettyError) => {
|
|
238
249
|
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
239
250
|
return {
|
|
@@ -246,7 +257,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
246
257
|
code: Custom,
|
|
247
258
|
message: prettyError.message,
|
|
248
259
|
data: {
|
|
249
|
-
stack: prettyError
|
|
260
|
+
stack: getStack(prettyError),
|
|
250
261
|
codeFrame: prettyError.codeFrame,
|
|
251
262
|
type: getErrorType(prettyError),
|
|
252
263
|
code: prettyError.code,
|