mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(user-menu) improve error handling
This commit is contained in:
parent
b8592d35c0
commit
64e6b8387a
5 changed files with 109 additions and 14 deletions
29
client/modules/user-menu/parse-error.js
Normal file
29
client/modules/user-menu/parse-error.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
const isNumber = (a) => typeof a === 'number';
|
||||
|
||||
module.exports = (error) => {
|
||||
const {
|
||||
lineNumber,
|
||||
columnNumber,
|
||||
} = error;
|
||||
|
||||
if (isNumber(lineNumber) && isNumber(columnNumber))
|
||||
return [
|
||||
lineNumber,
|
||||
columnNumber,
|
||||
];
|
||||
|
||||
const before = error.stack.indexOf('>');
|
||||
const str = error.stack.slice(before + 1);
|
||||
const after = str.indexOf(')');
|
||||
const newStr = str.slice(1, after);
|
||||
|
||||
const [line, column] = newStr.split(':');
|
||||
|
||||
return [
|
||||
Number(line),
|
||||
Number(column),
|
||||
];
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue