first commit
This commit is contained in:
25
app_vue/node_modules/pretty-error/.github/workflows/main.yml
generated
vendored
Normal file
25
app_vue/node_modules/pretty-error/.github/workflows/main.yml
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: Node.js CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x, 15.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm install
|
||||
- run: npm run compile
|
||||
- run: npm test
|
5
app_vue/node_modules/pretty-error/.mocharc.yaml
generated
vendored
Normal file
5
app_vue/node_modules/pretty-error/.mocharc.yaml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
require: 'coffee-script/register'
|
||||
recursive: true
|
||||
reporter: 'spec'
|
||||
ui: 'bdd'
|
||||
timeout: 20000
|
6
app_vue/node_modules/pretty-error/.travis.yml
generated
vendored
Normal file
6
app_vue/node_modules/pretty-error/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 10.16
|
||||
|
||||
sudo: false
|
5
app_vue/node_modules/pretty-error/CHANGELOG.md
generated
vendored
Normal file
5
app_vue/node_modules/pretty-error/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## `4.0.0`
|
||||
|
||||
* **Breaking Change**: Removed support for Node `<12.x`
|
20
app_vue/node_modules/pretty-error/LICENSE
generated
vendored
Normal file
20
app_vue/node_modules/pretty-error/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Aria Minaei
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
322
app_vue/node_modules/pretty-error/README.md
generated
vendored
Normal file
322
app_vue/node_modules/pretty-error/README.md
generated
vendored
Normal file
@ -0,0 +1,322 @@
|
||||
# pretty-error
|
||||
|
||||
[](https://david-dm.org/AriaMinaei/pretty-error)
|
||||
[](https://travis-ci.org/AriaMinaei/pretty-error) [](https://npmjs.org/package/pretty-error)
|
||||
|
||||
A small tool to see node.js errors with less clutter:
|
||||
|
||||

|
||||
|
||||
... which is more readable compared to node's unformatted errors:
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
Install with npm:
|
||||
|
||||
$ npm install pretty-error
|
||||
|
||||
## Usage and Examples
|
||||
|
||||
To see an error rendered with colors, you can do this:
|
||||
|
||||
```javascript
|
||||
var PrettyError = require('pretty-error');
|
||||
var pe = new PrettyError();
|
||||
|
||||
var renderedError = pe.render(new Error('Some error message'));
|
||||
console.log(renderedError);
|
||||
```
|
||||
|
||||
Of course, you can render caught exceptions too:
|
||||
|
||||
```javascript
|
||||
try {
|
||||
doSomethingThatThrowsAnError();
|
||||
} catch (error) {
|
||||
console.log(pe.render(error));
|
||||
}
|
||||
```
|
||||
|
||||
But if you want pretty-error to render all errors, there is a shortcut for it:
|
||||
|
||||
```javascript
|
||||
require('pretty-error').start();
|
||||
```
|
||||
|
||||
... which is essentially equal to:
|
||||
|
||||
```javascript
|
||||
var PrettyError = require('pretty-error');
|
||||
|
||||
// instantiate PrettyError, which can then be used to render error objects
|
||||
var pe = new PrettyError();
|
||||
pe.start();
|
||||
```
|
||||
|
||||
You can also preload pretty-error into your code using node's [`--require`](https://nodejs.org/api/cli.html#cli_r_require_module) argument:
|
||||
|
||||
```
|
||||
$ node --require pretty-error/start your-module.js
|
||||
```
|
||||
|
||||
## How it Works
|
||||
|
||||
PrettyError turns error objects into something similar to an html document, and then uses [RenderKid](https://github.com/AriaMinaei/renderkid) to render the document using simple html/css-like commands. This allows PrettyError to be themed using simple css-like declarations.
|
||||
|
||||
## Theming
|
||||
|
||||
PrettyError's default theme is a bunch of simple css-like rules. [Here](https://github.com/AriaMinaei/pretty-error/blob/master/src/defaultStyle.coffee) is the source of the default theme.
|
||||
|
||||
Since the default theme is all css, you can customize it to fit your taste. Let's do a minimal one:
|
||||
|
||||
```javascript
|
||||
// the start() shortcut returns an instance of PrettyError ...
|
||||
pe = require('pretty-error').start();
|
||||
|
||||
// ... which we can then use to customize like this:
|
||||
pe.appendStyle({
|
||||
// this is a simple selector to the element that says 'Error'
|
||||
'pretty-error > header > title > kind': {
|
||||
// which we can hide:
|
||||
display: 'none'
|
||||
},
|
||||
|
||||
// the 'colon' after 'Error':
|
||||
'pretty-error > header > colon': {
|
||||
// we hide that too:
|
||||
display: 'none'
|
||||
},
|
||||
|
||||
// our error message
|
||||
'pretty-error > header > message': {
|
||||
// let's change its color:
|
||||
color: 'bright-white',
|
||||
|
||||
// we can use black, red, green, yellow, blue, magenta, cyan, white,
|
||||
// grey, bright-red, bright-green, bright-yellow, bright-blue,
|
||||
// bright-magenta, bright-cyan, and bright-white
|
||||
|
||||
// we can also change the background color:
|
||||
background: 'cyan',
|
||||
|
||||
// it understands paddings too!
|
||||
padding: '0 1' // top/bottom left/right
|
||||
},
|
||||
|
||||
// each trace item ...
|
||||
'pretty-error > trace > item': {
|
||||
// ... can have a margin ...
|
||||
marginLeft: 2,
|
||||
|
||||
// ... and a bullet character!
|
||||
bullet: '"<grey>o</grey>"'
|
||||
|
||||
// Notes on bullets:
|
||||
//
|
||||
// The string inside the quotation mark gets used as the character
|
||||
// to show for the bullet point.
|
||||
//
|
||||
// You can set its color/background color using tags.
|
||||
//
|
||||
// This example sets the background color to white, and the text color
|
||||
// to cyan, the character will be a hyphen with a space character
|
||||
// on each side:
|
||||
// example: '"<bg-white><cyan> - </cyan></bg-white>"'
|
||||
//
|
||||
// Note that we should use a margin of 3, since the bullet will be
|
||||
// 3 characters long.
|
||||
},
|
||||
|
||||
'pretty-error > trace > item > header > pointer > file': {
|
||||
color: 'bright-cyan'
|
||||
},
|
||||
|
||||
'pretty-error > trace > item > header > pointer > colon': {
|
||||
color: 'cyan'
|
||||
},
|
||||
|
||||
'pretty-error > trace > item > header > pointer > line': {
|
||||
color: 'bright-cyan'
|
||||
},
|
||||
|
||||
'pretty-error > trace > item > header > what': {
|
||||
color: 'bright-white'
|
||||
},
|
||||
|
||||
'pretty-error > trace > item > footer > addr': {
|
||||
display: 'none'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
This is how our minimal theme will look like: 
|
||||
|
||||
Read [RenderKid](https://github.com/AriaMinaei/renderkid)'s docs to learn about all the css rules that are supported.
|
||||
|
||||
## Customization
|
||||
|
||||
There are a few methods to help you customize the contents of your error logs.
|
||||
|
||||
Let's instantiate first:
|
||||
|
||||
```javascript
|
||||
PrettyError = require('pretty-error');
|
||||
pe = new PrettyError();
|
||||
|
||||
// or:
|
||||
pe = require('pretty-error').start();
|
||||
```
|
||||
|
||||
#### Shortening paths
|
||||
|
||||
You might want to substitute long paths with shorter, more readable aliases:
|
||||
|
||||
```javascript
|
||||
pe.alias('E:/open-source/theatrejs/lib', '(Theatre.js)');
|
||||
```
|
||||
|
||||
#### Skipping packages
|
||||
|
||||
You might want to skip trace lines that belong to specific packages (chai, when, socket.io):
|
||||
|
||||
```javascript
|
||||
pe.skipPackage('chai', 'when', 'socket.io');
|
||||
```
|
||||
|
||||
#### Skipping node files
|
||||
|
||||
```javascript
|
||||
// this will skip node.js, path.js, event.js, etc.
|
||||
pe.skipNodeFiles();
|
||||
```
|
||||
|
||||
#### Skipping paths
|
||||
|
||||
```javascript
|
||||
pe.skipPath('/home/dir/someFile.js');
|
||||
```
|
||||
|
||||
#### Skipping by callback
|
||||
|
||||
You can customize which trace lines get logged and which won't:
|
||||
```javascript
|
||||
pe.skip(function(traceLine, lineNumber){
|
||||
// if we know which package this trace line comes from, and it isn't
|
||||
// our 'demo' package ...
|
||||
if (typeof traceLine.packageName !== 'undefined' && traceLine.packageName !== 'demo') {
|
||||
// then skip this line
|
||||
return true;
|
||||
}
|
||||
|
||||
// You can console.log(traceLine) to see all of it's properties.
|
||||
// Don't expect all these properties to be present, and don't assume
|
||||
// that our traceLine is always an object.
|
||||
});
|
||||
```
|
||||
|
||||
#### Modifying each trace line's contents
|
||||
|
||||
```javascript
|
||||
pe.filter(function(traceLine, lineNumber){
|
||||
// the 'what' clause is something like:
|
||||
// 'DynamicTimeline.module.exports.DynamicTimeline._verifyProp'
|
||||
if (typeof traceLine.what !== 'undefined'){
|
||||
|
||||
// we can shorten it with a regex:
|
||||
traceLine.what = traceLine.what.replace(
|
||||
/(.*\.module\.exports\.)(.*)/, '$2'
|
||||
);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Disabling colors
|
||||
```javascript
|
||||
pe.withoutColors(); // Errors will be rendered without coloring
|
||||
```
|
||||
|
||||
## Integrating with frameworks
|
||||
|
||||
PrettyError is very simple to set up, so it should be easy to use within other frameworks.
|
||||
|
||||
### Integrating with [express](https://github.com/visionmedia/express)
|
||||
|
||||
Most frameworks such as express, catch errors automatically and provide a mechanism to handle those errors. Here is an example of how you can use PrettyError to log unhandled errors in express:
|
||||
|
||||
```javascript
|
||||
// this is app.js
|
||||
|
||||
var express = require('express');
|
||||
var PrettyError = require('pretty-error');
|
||||
|
||||
var app = express();
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
// this will throw an error:
|
||||
var a = b;
|
||||
});
|
||||
|
||||
var server = app.listen(3000, function(){
|
||||
console.log('Server started \n');
|
||||
});
|
||||
|
||||
|
||||
// we can now instantiaite Prettyerror:
|
||||
pe = new PrettyError();
|
||||
|
||||
// and use it for our app's error handler:
|
||||
app.use(function(err, req, res, next){
|
||||
console.log(pe.render(err));
|
||||
next();
|
||||
});
|
||||
|
||||
// we can optionally configure prettyError to simplify the stack trace:
|
||||
|
||||
pe.skipNodeFiles(); // this will skip events.js and http.js and similar core node files
|
||||
pe.skipPackage('express'); // this will skip all the trace lines about express` core and sub-modules
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
`PrettyError.start()` modifies the stack traces of all errors thrown anywhere in your code, so it could potentially break packages that rely on node's original stack traces. I've only encountered this problem once, and it was with BlueBird when `Promise.longStackTraces()` was on.
|
||||
|
||||
In order to avoid this problem, it's better to not use `PrettyError.start()` and instead, manually catch errors and render them with PrettyError:
|
||||
|
||||
```javascript
|
||||
var PrettyError = require('pretty-error');
|
||||
var pe = new PrettyError();
|
||||
|
||||
// To render exceptions thrown in non-promies code:
|
||||
process.on('uncaughtException', function(error){
|
||||
console.log(pe.render(error));
|
||||
});
|
||||
|
||||
// To render unhandled rejections created in BlueBird:
|
||||
process.on('unhandledRejection', function(reason){
|
||||
console.log("Unhandled rejection");
|
||||
console.log(pe.render(reason));
|
||||
});
|
||||
|
||||
// While PrettyError.start() works out of the box with when.js` unhandled rejections,
|
||||
// now that wer'e manually rendering errors, we have to instead use npmjs.org/packages/pretty-monitor
|
||||
// to handle when.js rejections.
|
||||
|
||||
```
|
||||
|
||||
The only drawback with this approach is that exceptions thrown in the first tick are not prettified. To fix that, you can delay your application's startup for one tick:
|
||||
|
||||
```javascript
|
||||
// (continued form above)
|
||||
|
||||
throw new Error(); // not prettified
|
||||
process.nextTick(function(){
|
||||
throw new Error(); // prettified
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
66
app_vue/node_modules/pretty-error/index.d.ts
generated
vendored
Normal file
66
app_vue/node_modules/pretty-error/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
declare module 'pretty-error' {
|
||||
namespace PrettyError {
|
||||
function start(): any;
|
||||
function stop(): any;
|
||||
|
||||
class ParsedError {
|
||||
constructor(error: Error);
|
||||
}
|
||||
|
||||
interface ConfigObject {
|
||||
skipPackages?: boolean | string[];
|
||||
skipPaths?: boolean | string[];
|
||||
skip?: boolean | PrettyError.Callback | PrettyError.Callback[];
|
||||
maxItems?: number;
|
||||
skipNodeFiles?: boolean | any; // assuming this is optional
|
||||
filters?: boolean | PrettyError.Callback | PrettyError.Callback[];
|
||||
parsedErrorFilters?:
|
||||
| boolean
|
||||
| PrettyError.Callback
|
||||
| PrettyError.Callback[];
|
||||
aliases?: boolean | Object;
|
||||
}
|
||||
|
||||
type Callback = (traceLine: Object | any, lineNumber: number) => boolean;
|
||||
}
|
||||
|
||||
class PrettyError {
|
||||
constructor();
|
||||
|
||||
start(): PrettyError;
|
||||
stop(): any;
|
||||
config(configObject: PrettyError.ConfigObject): PrettyError;
|
||||
withoutColors(): PrettyError;
|
||||
withColors(): PrettyError;
|
||||
skipPackage(...packages: string[]): PrettyError;
|
||||
unskipPackage(...packages: string[]): PrettyError;
|
||||
unskipAllPackages(): PrettyError;
|
||||
skipPath(...paths: string[]): PrettyError;
|
||||
unskipPath(...paths: string[]): PrettyError;
|
||||
unskipAllPaths(): PrettyError;
|
||||
skip(callbacks: PrettyError.Callback): PrettyError;
|
||||
unskip(callbacks: PrettyError.Callback): PrettyError;
|
||||
unskipAll(): PrettyError;
|
||||
skipNodeFiles(): any;
|
||||
unskipNodeFiles(): any;
|
||||
filter(callbacks: PrettyError.Callback): PrettyError;
|
||||
removeFilter(callbacks: PrettyError.Callback): PrettyError;
|
||||
removeAllFilters(): PrettyError;
|
||||
filterParsedError(callbacks: PrettyError.Callback): PrettyError;
|
||||
removeParsedErrorFilter(callbacks: PrettyError.Callback): PrettyError;
|
||||
removeAllParsedErrorFilters(): PrettyError;
|
||||
setMaxItems(maxItems: number): PrettyError;
|
||||
alias(stringOrRx: string, alias: string): PrettyError;
|
||||
removeAlias(stringOrRx: string): PrettyError;
|
||||
removeAllAliases(): PrettyError;
|
||||
appendStyle(toAppend: Object): PrettyError;
|
||||
render(
|
||||
e: PrettyError.ParsedError,
|
||||
logIt?: boolean,
|
||||
useColors?: boolean
|
||||
): string;
|
||||
getObject(e: Object): Object;
|
||||
}
|
||||
|
||||
export = PrettyError;
|
||||
}
|
247
app_vue/node_modules/pretty-error/lib/ParsedError.js
generated
vendored
Normal file
247
app_vue/node_modules/pretty-error/lib/ParsedError.js
generated
vendored
Normal file
@ -0,0 +1,247 @@
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
var ParsedError, prop, sysPath, _fn, _i, _len, _ref;
|
||||
|
||||
sysPath = require('path');
|
||||
|
||||
module.exports = ParsedError = (function() {
|
||||
function ParsedError(error) {
|
||||
this.error = error;
|
||||
this._parse();
|
||||
}
|
||||
|
||||
ParsedError.prototype._parse = function() {
|
||||
var m;
|
||||
this._trace = [];
|
||||
this._kind = 'Error';
|
||||
this._wrapper = '';
|
||||
if (this.error.wrapper != null) {
|
||||
this._wrapper = String(this.error.wrapper);
|
||||
}
|
||||
if (typeof this.error !== 'object') {
|
||||
this._message = String(this.error);
|
||||
} else {
|
||||
this._stack = this.error.stack;
|
||||
if (this.error.kind != null) {
|
||||
this._kind = String(this.error.kind);
|
||||
} else if (typeof this._stack === 'string') {
|
||||
if (m = this._stack.match(/^([a-zA-Z0-9\_\$]+):\ /)) {
|
||||
this._kind = m[1];
|
||||
}
|
||||
}
|
||||
this._message = (this.error.message != null) && String(this.error.message) || '';
|
||||
if (typeof this._stack === 'string') {
|
||||
this._parseStack();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ParsedError.prototype._parseStack = function() {
|
||||
var line, message, messageLines, reachedTrace, _i, _len, _ref;
|
||||
messageLines = [];
|
||||
reachedTrace = false;
|
||||
_ref = this._stack.split('\n');
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
line = _ref[_i];
|
||||
if (line.trim() === '') {
|
||||
continue;
|
||||
}
|
||||
if (reachedTrace) {
|
||||
this._trace.push(this._parseTraceItem(line));
|
||||
} else {
|
||||
if (line.match(/^\s*at\s.+/)) {
|
||||
reachedTrace = true;
|
||||
this._trace.push(this._parseTraceItem(line));
|
||||
} else if (!this._message.split('\n'.indexOf(line))) {
|
||||
messageLines.push(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
message = messageLines.join('\n');
|
||||
if (message.substr(0, this._kind.length) === this._kind) {
|
||||
message = message.substr(this._kind.length, message.length).replace(/^\:\s+/, '');
|
||||
}
|
||||
if (message.length) {
|
||||
this._message = this._message.length ? [this._message, message].join('\n') : message;
|
||||
}
|
||||
};
|
||||
|
||||
ParsedError.prototype._parseTraceItem = function(text) {
|
||||
var addr, col, d, dir, file, jsCol, jsLine, line, m, original, packageName, packages, path, r, remaining, shortenedAddr, shortenedPath, what;
|
||||
text = text.trim();
|
||||
if (text === '') {
|
||||
return;
|
||||
}
|
||||
if (!text.match(/^at\ /)) {
|
||||
return text;
|
||||
}
|
||||
text = text.replace(/^at /, '');
|
||||
if (text === 'Error (<anonymous>)' || text === 'Error (<anonymous>:null:null)') {
|
||||
return;
|
||||
}
|
||||
original = text;
|
||||
what = null;
|
||||
addr = null;
|
||||
path = null;
|
||||
dir = null;
|
||||
file = null;
|
||||
line = null;
|
||||
col = null;
|
||||
jsLine = null;
|
||||
jsCol = null;
|
||||
shortenedPath = null;
|
||||
shortenedAddr = null;
|
||||
packageName = '[current]';
|
||||
if (m = text.match(/\(([^\)]+)\)$/)) {
|
||||
addr = m[1].trim();
|
||||
}
|
||||
if (addr != null) {
|
||||
what = text.substr(0, text.length - addr.length - 2);
|
||||
what = what.trim();
|
||||
}
|
||||
if (addr == null) {
|
||||
addr = text.trim();
|
||||
}
|
||||
addr = this._fixPath(addr);
|
||||
remaining = addr;
|
||||
if (m = remaining.match(/\,\ <js>:(\d+):(\d+)$/)) {
|
||||
jsLine = m[1];
|
||||
jsCol = m[2];
|
||||
remaining = remaining.substr(0, remaining.length - m[0].length);
|
||||
}
|
||||
if (m = remaining.match(/:(\d+):(\d+)$/)) {
|
||||
line = m[1];
|
||||
col = m[2];
|
||||
remaining = remaining.substr(0, remaining.length - m[0].length);
|
||||
path = remaining;
|
||||
}
|
||||
if (path != null) {
|
||||
file = sysPath.basename(path);
|
||||
dir = sysPath.dirname(path);
|
||||
if (dir === '.') {
|
||||
dir = '';
|
||||
}
|
||||
path = this._fixPath(path);
|
||||
file = this._fixPath(file);
|
||||
dir = this._fixPath(dir);
|
||||
}
|
||||
if (dir != null) {
|
||||
d = dir.replace(/[\\]{1,2}/g, '/');
|
||||
if (m = d.match(/node_modules\/([^\/]+)(?!.*node_modules.*)/)) {
|
||||
packageName = m[1];
|
||||
}
|
||||
}
|
||||
if (jsLine == null) {
|
||||
jsLine = line;
|
||||
jsCol = col;
|
||||
}
|
||||
if (path != null) {
|
||||
r = this._rectifyPath(path);
|
||||
shortenedPath = r.path;
|
||||
shortenedAddr = shortenedPath + addr.substr(path.length, addr.length);
|
||||
packages = r.packages;
|
||||
}
|
||||
return {
|
||||
original: original,
|
||||
what: what,
|
||||
addr: addr,
|
||||
path: path,
|
||||
dir: dir,
|
||||
file: file,
|
||||
line: parseInt(line),
|
||||
col: parseInt(col),
|
||||
jsLine: parseInt(jsLine),
|
||||
jsCol: parseInt(jsCol),
|
||||
packageName: packageName,
|
||||
shortenedPath: shortenedPath,
|
||||
shortenedAddr: shortenedAddr,
|
||||
packages: packages || []
|
||||
};
|
||||
};
|
||||
|
||||
ParsedError.prototype._getMessage = function() {
|
||||
return this._message;
|
||||
};
|
||||
|
||||
ParsedError.prototype._getKind = function() {
|
||||
return this._kind;
|
||||
};
|
||||
|
||||
ParsedError.prototype._getWrapper = function() {
|
||||
return this._wrapper;
|
||||
};
|
||||
|
||||
ParsedError.prototype._getStack = function() {
|
||||
return this._stack;
|
||||
};
|
||||
|
||||
ParsedError.prototype._getArguments = function() {
|
||||
return this.error["arguments"];
|
||||
};
|
||||
|
||||
ParsedError.prototype._getType = function() {
|
||||
return this.error.type;
|
||||
};
|
||||
|
||||
ParsedError.prototype._getTrace = function() {
|
||||
return this._trace;
|
||||
};
|
||||
|
||||
ParsedError.prototype._fixPath = function(path) {
|
||||
return path.replace(/[\\]{1,2}/g, '/');
|
||||
};
|
||||
|
||||
ParsedError.prototype._rectifyPath = function(path, nameForCurrentPackage) {
|
||||
var m, packages, parts, remaining, rest;
|
||||
path = String(path);
|
||||
remaining = path;
|
||||
if (!(m = path.match(/^(.+?)\/node_modules\/(.+)$/))) {
|
||||
return {
|
||||
path: path,
|
||||
packages: []
|
||||
};
|
||||
}
|
||||
parts = [];
|
||||
packages = [];
|
||||
if (typeof nameForCurrentPackage === 'string') {
|
||||
parts.push("[" + nameForCurrentPackage + "]");
|
||||
packages.push("[" + nameForCurrentPackage + "]");
|
||||
} else {
|
||||
parts.push("[" + (m[1].match(/([^\/]+)$/)[1]) + "]");
|
||||
packages.push(m[1].match(/([^\/]+)$/)[1]);
|
||||
}
|
||||
rest = m[2];
|
||||
while (m = rest.match(/([^\/]+)\/node_modules\/(.+)$/)) {
|
||||
parts.push("[" + m[1] + "]");
|
||||
packages.push(m[1]);
|
||||
rest = m[2];
|
||||
}
|
||||
if (m = rest.match(/([^\/]+)\/(.+)$/)) {
|
||||
parts.push("[" + m[1] + "]");
|
||||
packages.push(m[1]);
|
||||
rest = m[2];
|
||||
}
|
||||
parts.push(rest);
|
||||
return {
|
||||
path: parts.join("/"),
|
||||
packages: packages
|
||||
};
|
||||
};
|
||||
|
||||
return ParsedError;
|
||||
|
||||
})();
|
||||
|
||||
_ref = ['message', 'kind', 'arguments', 'type', 'stack', 'trace', 'wrapper'];
|
||||
_fn = function() {
|
||||
var methodName;
|
||||
methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length);
|
||||
return Object.defineProperty(ParsedError.prototype, prop, {
|
||||
get: function() {
|
||||
return this[methodName]();
|
||||
}
|
||||
});
|
||||
};
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
prop = _ref[_i];
|
||||
_fn();
|
||||
}
|
552
app_vue/node_modules/pretty-error/lib/PrettyError.js
generated
vendored
Normal file
552
app_vue/node_modules/pretty-error/lib/PrettyError.js
generated
vendored
Normal file
@ -0,0 +1,552 @@
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
var ParsedError, PrettyError, RenderKid, arrayUtils, defaultStyle, instance, isPlainObject, merge, nodePaths, prop, _fn, _i, _len, _ref,
|
||||
__slice = [].slice,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
isPlainObject = require('lodash/isPlainObject');
|
||||
|
||||
defaultStyle = require('./defaultStyle');
|
||||
|
||||
ParsedError = require('./ParsedError');
|
||||
|
||||
nodePaths = require('./nodePaths');
|
||||
|
||||
RenderKid = require('renderkid');
|
||||
|
||||
merge = require('lodash/merge');
|
||||
|
||||
arrayUtils = {
|
||||
pluckByCallback: function(a, cb) {
|
||||
var index, removed, value, _i, _len;
|
||||
if (a.length < 1) {
|
||||
return a;
|
||||
}
|
||||
removed = 0;
|
||||
for (index = _i = 0, _len = a.length; _i < _len; index = ++_i) {
|
||||
value = a[index];
|
||||
if (cb(value, index)) {
|
||||
removed++;
|
||||
continue;
|
||||
}
|
||||
if (removed !== 0) {
|
||||
a[index - removed] = a[index];
|
||||
}
|
||||
}
|
||||
if (removed > 0) {
|
||||
a.length = a.length - removed;
|
||||
}
|
||||
return a;
|
||||
},
|
||||
pluckOneItem: function(a, item) {
|
||||
var index, reached, value, _i, _len;
|
||||
if (a.length < 1) {
|
||||
return a;
|
||||
}
|
||||
reached = false;
|
||||
for (index = _i = 0, _len = a.length; _i < _len; index = ++_i) {
|
||||
value = a[index];
|
||||
if (!reached) {
|
||||
if (value === item) {
|
||||
reached = true;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
a[index - 1] = a[index];
|
||||
}
|
||||
}
|
||||
if (reached) {
|
||||
a.length = a.length - 1;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
instance = null;
|
||||
|
||||
module.exports = PrettyError = (function() {
|
||||
var self;
|
||||
|
||||
self = PrettyError;
|
||||
|
||||
PrettyError._filters = {
|
||||
'module.exports': function(item) {
|
||||
if (item.what == null) {
|
||||
return;
|
||||
}
|
||||
item.what = item.what.replace(/\.module\.exports\./g, ' - ');
|
||||
}
|
||||
};
|
||||
|
||||
PrettyError._getDefaultStyle = function() {
|
||||
return defaultStyle();
|
||||
};
|
||||
|
||||
PrettyError.start = function() {
|
||||
if (instance == null) {
|
||||
instance = new self;
|
||||
instance.start();
|
||||
}
|
||||
return instance;
|
||||
};
|
||||
|
||||
PrettyError.stop = function() {
|
||||
return instance != null ? instance.stop() : void 0;
|
||||
};
|
||||
|
||||
function PrettyError() {
|
||||
this._useColors = true;
|
||||
this._maxItems = 50;
|
||||
this._packagesToSkip = [];
|
||||
this._pathsToSkip = [];
|
||||
this._skipCallbacks = [];
|
||||
this._filterCallbacks = [];
|
||||
this._parsedErrorFilters = [];
|
||||
this._aliases = [];
|
||||
this._renderer = new RenderKid;
|
||||
this._style = self._getDefaultStyle();
|
||||
this._renderer.style(this._style);
|
||||
}
|
||||
|
||||
PrettyError.prototype.start = function() {
|
||||
var prepeare;
|
||||
this._oldPrepareStackTrace = Error.prepareStackTrace;
|
||||
prepeare = this._oldPrepareStackTrace || function(exc, frames) {
|
||||
var result;
|
||||
result = exc.toString();
|
||||
frames = frames.map(function(frame) {
|
||||
return " at " + (frame.toString());
|
||||
});
|
||||
return result + "\n" + frames.join("\n");
|
||||
};
|
||||
Error.prepareStackTrace = (function(_this) {
|
||||
return function(exc, trace) {
|
||||
var stack;
|
||||
stack = prepeare.apply(null, arguments);
|
||||
return _this.render({
|
||||
stack: stack,
|
||||
message: exc.toString().replace(/^.*: /, '')
|
||||
}, false);
|
||||
};
|
||||
})(this);
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.stop = function() {
|
||||
Error.prepareStackTrace = this._oldPrepareStackTrace;
|
||||
return this._oldPrepareStackTrace = null;
|
||||
};
|
||||
|
||||
PrettyError.prototype.config = function(c) {
|
||||
var alias, path, _ref;
|
||||
if (c.skipPackages != null) {
|
||||
if (c.skipPackages === false) {
|
||||
this.unskipAllPackages();
|
||||
} else {
|
||||
this.skipPackage.apply(this, c.skipPackages);
|
||||
}
|
||||
}
|
||||
if (c.skipPaths != null) {
|
||||
if (c.skipPaths === false) {
|
||||
this.unskipAllPaths();
|
||||
} else {
|
||||
this.skipPath.apply(this, c.skipPaths);
|
||||
}
|
||||
}
|
||||
if (c.skip != null) {
|
||||
if (c.skip === false) {
|
||||
this.unskipAll();
|
||||
} else {
|
||||
this.skip.apply(this, c.skip);
|
||||
}
|
||||
}
|
||||
if (c.maxItems != null) {
|
||||
this.setMaxItems(c.maxItems);
|
||||
}
|
||||
if (c.skipNodeFiles === true) {
|
||||
this.skipNodeFiles();
|
||||
} else if (c.skipNodeFiles === false) {
|
||||
this.unskipNodeFiles();
|
||||
}
|
||||
if (c.filters != null) {
|
||||
if (c.filters === false) {
|
||||
this.removeAllFilters();
|
||||
} else {
|
||||
this.filter.apply(this, c.filters);
|
||||
}
|
||||
}
|
||||
if (c.parsedErrorFilters != null) {
|
||||
if (c.parsedErrorFilters === false) {
|
||||
this.removeAllParsedErrorFilters();
|
||||
} else {
|
||||
this.filterParsedError.apply(this, c.parsedErrorFilters);
|
||||
}
|
||||
}
|
||||
if (c.aliases != null) {
|
||||
if (isPlainObject(c.aliases)) {
|
||||
_ref = c.aliases;
|
||||
for (path in _ref) {
|
||||
alias = _ref[path];
|
||||
this.alias(path, alias);
|
||||
}
|
||||
} else if (c.aliases === false) {
|
||||
this.removeAllAliases();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.withoutColors = function() {
|
||||
this._useColors = false;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.withColors = function() {
|
||||
this._useColors = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.skipPackage = function() {
|
||||
var packages, pkg, _i, _len;
|
||||
packages = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = packages.length; _i < _len; _i++) {
|
||||
pkg = packages[_i];
|
||||
this._packagesToSkip.push(String(pkg));
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.unskipPackage = function() {
|
||||
var packages, pkg, _i, _len;
|
||||
packages = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = packages.length; _i < _len; _i++) {
|
||||
pkg = packages[_i];
|
||||
arrayUtils.pluckOneItem(this._packagesToSkip, pkg);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.unskipAllPackages = function() {
|
||||
this._packagesToSkip.length = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.skipPath = function() {
|
||||
var path, paths, _i, _len;
|
||||
paths = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = paths.length; _i < _len; _i++) {
|
||||
path = paths[_i];
|
||||
this._pathsToSkip.push(path);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.unskipPath = function() {
|
||||
var path, paths, _i, _len;
|
||||
paths = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = paths.length; _i < _len; _i++) {
|
||||
path = paths[_i];
|
||||
arrayUtils.pluckOneItem(this._pathsToSkip, path);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.unskipAllPaths = function() {
|
||||
this._pathsToSkip.length = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.skip = function() {
|
||||
var callbacks, cb, _i, _len;
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
this._skipCallbacks.push(cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.unskip = function() {
|
||||
var callbacks, cb, _i, _len;
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
arrayUtils.pluckOneItem(this._skipCallbacks, cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.unskipAll = function() {
|
||||
this._skipCallbacks.length = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.skipNodeFiles = function() {
|
||||
return this.skipPath.apply(this, nodePaths);
|
||||
};
|
||||
|
||||
PrettyError.prototype.unskipNodeFiles = function() {
|
||||
return this.unskipPath.apply(this, nodePaths);
|
||||
};
|
||||
|
||||
PrettyError.prototype.filter = function() {
|
||||
var callbacks, cb, _i, _len;
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
this._filterCallbacks.push(cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.removeFilter = function() {
|
||||
var callbacks, cb, _i, _len;
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
arrayUtils.pluckOneItem(this._filterCallbacks, cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.removeAllFilters = function() {
|
||||
this._filterCallbacks.length = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.filterParsedError = function() {
|
||||
var callbacks, cb, _i, _len;
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
this._parsedErrorFilters.push(cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.removeParsedErrorFilter = function() {
|
||||
var callbacks, cb, _i, _len;
|
||||
callbacks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
for (_i = 0, _len = callbacks.length; _i < _len; _i++) {
|
||||
cb = callbacks[_i];
|
||||
arrayUtils.pluckOneItem(this._parsedErrorFilters, cb);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.removeAllParsedErrorFilters = function() {
|
||||
this._parsedErrorFilters.length = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.setMaxItems = function(maxItems) {
|
||||
if (maxItems == null) {
|
||||
maxItems = 50;
|
||||
}
|
||||
if (maxItems === 0) {
|
||||
maxItems = 50;
|
||||
}
|
||||
this._maxItems = maxItems | 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.alias = function(stringOrRx, alias) {
|
||||
this._aliases.push({
|
||||
stringOrRx: stringOrRx,
|
||||
alias: alias
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.removeAlias = function(stringOrRx) {
|
||||
arrayUtils.pluckByCallback(this._aliases, function(pair) {
|
||||
return pair.stringOrRx === stringOrRx;
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype.removeAllAliases = function() {
|
||||
this._aliases.length = 0;
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype._getStyle = function() {
|
||||
return this._style;
|
||||
};
|
||||
|
||||
PrettyError.prototype.appendStyle = function(toAppend) {
|
||||
merge(this._style, toAppend);
|
||||
this._renderer.style(toAppend);
|
||||
return this;
|
||||
};
|
||||
|
||||
PrettyError.prototype._getRenderer = function() {
|
||||
return this._renderer;
|
||||
};
|
||||
|
||||
PrettyError.prototype.render = function(e, logIt, useColors) {
|
||||
var obj, rendered;
|
||||
if (logIt == null) {
|
||||
logIt = false;
|
||||
}
|
||||
if (useColors == null) {
|
||||
useColors = this._useColors;
|
||||
}
|
||||
obj = this.getObject(e);
|
||||
rendered = this._renderer.render(obj, useColors);
|
||||
if (logIt === true) {
|
||||
console.error(rendered);
|
||||
}
|
||||
return rendered;
|
||||
};
|
||||
|
||||
PrettyError.prototype.getObject = function(e) {
|
||||
var count, header, i, item, obj, traceItems, _i, _len, _ref;
|
||||
if (!(e instanceof ParsedError)) {
|
||||
e = new ParsedError(e);
|
||||
}
|
||||
this._applyParsedErrorFiltersOn(e);
|
||||
header = {
|
||||
title: (function() {
|
||||
var ret;
|
||||
ret = {};
|
||||
if (e.wrapper !== '') {
|
||||
ret.wrapper = "" + e.wrapper;
|
||||
}
|
||||
ret.kind = e.kind;
|
||||
return ret;
|
||||
})(),
|
||||
colon: ':',
|
||||
message: String(e.message).trim()
|
||||
};
|
||||
traceItems = [];
|
||||
count = -1;
|
||||
_ref = e.trace;
|
||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
||||
item = _ref[i];
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (this._skipOrFilter(item, i) === true) {
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
if (count > this._maxItems) {
|
||||
break;
|
||||
}
|
||||
if (typeof item === 'string') {
|
||||
traceItems.push({
|
||||
item: {
|
||||
custom: item
|
||||
}
|
||||
});
|
||||
continue;
|
||||
}
|
||||
traceItems.push((function() {
|
||||
var markupItem;
|
||||
markupItem = {
|
||||
item: {
|
||||
header: {
|
||||
pointer: (function() {
|
||||
if (item.file == null) {
|
||||
return '';
|
||||
}
|
||||
return {
|
||||
file: item.file,
|
||||
colon: ':',
|
||||
line: item.line
|
||||
};
|
||||
})()
|
||||
},
|
||||
footer: (function() {
|
||||
var foooter;
|
||||
foooter = {
|
||||
addr: item.shortenedAddr
|
||||
};
|
||||
if (item.extra != null) {
|
||||
foooter.extra = item.extra;
|
||||
}
|
||||
return foooter;
|
||||
})()
|
||||
}
|
||||
};
|
||||
if (typeof item.what === 'string' && item.what.trim().length > 0) {
|
||||
markupItem.item.header.what = item.what;
|
||||
}
|
||||
return markupItem;
|
||||
})());
|
||||
}
|
||||
obj = {
|
||||
'pretty-error': {
|
||||
header: header
|
||||
}
|
||||
};
|
||||
if (traceItems.length > 0) {
|
||||
obj['pretty-error'].trace = traceItems;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
|
||||
PrettyError.prototype._skipOrFilter = function(item, itemNumber) {
|
||||
var cb, modName, pair, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
|
||||
if (typeof item === 'object') {
|
||||
if (_ref = item.modName, __indexOf.call(this._packagesToSkip, _ref) >= 0) {
|
||||
return true;
|
||||
}
|
||||
if (_ref1 = item.path, __indexOf.call(this._pathsToSkip, _ref1) >= 0) {
|
||||
return true;
|
||||
}
|
||||
_ref2 = item.packages;
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
modName = _ref2[_i];
|
||||
if (__indexOf.call(this._packagesToSkip, modName) >= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (typeof item.shortenedAddr === 'string') {
|
||||
_ref3 = this._aliases;
|
||||
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
|
||||
pair = _ref3[_j];
|
||||
item.shortenedAddr = item.shortenedAddr.replace(pair.stringOrRx, pair.alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ref4 = this._skipCallbacks;
|
||||
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
|
||||
cb = _ref4[_k];
|
||||
if (cb(item, itemNumber) === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_ref5 = this._filterCallbacks;
|
||||
for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) {
|
||||
cb = _ref5[_l];
|
||||
cb(item, itemNumber);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
PrettyError.prototype._applyParsedErrorFiltersOn = function(error) {
|
||||
var cb, _i, _len, _ref;
|
||||
_ref = this._parsedErrorFilters;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
cb = _ref[_i];
|
||||
cb(error);
|
||||
}
|
||||
};
|
||||
|
||||
return PrettyError;
|
||||
|
||||
})();
|
||||
|
||||
_ref = ['renderer', 'style'];
|
||||
_fn = function() {
|
||||
var methodName;
|
||||
methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length);
|
||||
return PrettyError.prototype.__defineGetter__(prop, function() {
|
||||
return this[methodName]();
|
||||
});
|
||||
};
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
prop = _ref[_i];
|
||||
_fn();
|
||||
}
|
64
app_vue/node_modules/pretty-error/lib/defaultStyle.js
generated
vendored
Normal file
64
app_vue/node_modules/pretty-error/lib/defaultStyle.js
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
module.exports = function() {
|
||||
return {
|
||||
'pretty-error': {
|
||||
display: 'block',
|
||||
marginLeft: '2'
|
||||
},
|
||||
'pretty-error > header': {
|
||||
display: 'block'
|
||||
},
|
||||
'pretty-error > header > title > kind': {
|
||||
background: 'red',
|
||||
color: 'bright-white'
|
||||
},
|
||||
'pretty-error > header > title > wrapper': {
|
||||
marginRight: '1',
|
||||
color: 'grey'
|
||||
},
|
||||
'pretty-error > header > colon': {
|
||||
color: 'grey',
|
||||
marginRight: 1
|
||||
},
|
||||
'pretty-error > header > message': {
|
||||
color: 'bright-white'
|
||||
},
|
||||
'pretty-error > trace': {
|
||||
display: 'block',
|
||||
marginTop: 1
|
||||
},
|
||||
'pretty-error > trace > item': {
|
||||
display: 'block',
|
||||
marginBottom: 1,
|
||||
marginLeft: 2,
|
||||
bullet: '"<grey>-</grey>"'
|
||||
},
|
||||
'pretty-error > trace > item > header': {
|
||||
display: 'block'
|
||||
},
|
||||
'pretty-error > trace > item > header > pointer > file': {
|
||||
color: 'bright-yellow'
|
||||
},
|
||||
'pretty-error > trace > item > header > pointer > colon': {
|
||||
color: 'grey'
|
||||
},
|
||||
'pretty-error > trace > item > header > pointer > line': {
|
||||
color: 'bright-yellow',
|
||||
marginRight: 1
|
||||
},
|
||||
'pretty-error > trace > item > header > what': {
|
||||
color: 'white'
|
||||
},
|
||||
'pretty-error > trace > item > footer': {
|
||||
display: 'block'
|
||||
},
|
||||
'pretty-error > trace > item > footer > addr': {
|
||||
display: 'block',
|
||||
color: 'grey'
|
||||
},
|
||||
'pretty-error > trace > item > footer > extra': {
|
||||
display: 'block',
|
||||
color: 'grey'
|
||||
}
|
||||
};
|
||||
};
|
2
app_vue/node_modules/pretty-error/lib/nodePaths.js
generated
vendored
Normal file
2
app_vue/node_modules/pretty-error/lib/nodePaths.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
// Generated by CoffeeScript 1.8.0
|
||||
module.exports = ['_debugger.js', '_http_agent.js', '_http_client.js', '_http_common.js', '_http_incoming.js', '_http_outgoing.js', '_http_server.js', '_linklist.js', '_stream_duplex.js', '_stream_passthrough.js', '_stream_readable.js', '_stream_transform.js', '_stream_writable.js', '_tls_legacy.js', '_tls_wrap.js', 'assert.js', 'buffer.js', 'child_process.js', 'cluster.js', 'console.js', 'constants.js', 'crypto.js', 'dgram.js', 'dns.js', 'domain.js', 'events.js', 'freelist.js', 'fs.js', 'http.js', 'https.js', 'module.js', 'net.js', 'os.js', 'path.js', 'punycode.js', 'querystring.js', 'readline.js', 'repl.js', 'smalloc.js', 'stream.js', 'string_decoder.js', 'sys.js', 'timers.js', 'tls.js', 'tty.js', 'url.js', 'util.js', 'vm.js', 'zlib.js', 'node.js'];
|
48
app_vue/node_modules/pretty-error/package.json
generated
vendored
Normal file
48
app_vue/node_modules/pretty-error/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "pretty-error",
|
||||
"version": "4.0.0",
|
||||
"description": "See nodejs errors with less clutter",
|
||||
"main": "./lib/PrettyError.js",
|
||||
"typings": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "mocha \"test/**/*.coffee\"",
|
||||
"test:watch": "mocha \"test/**/*.coffee\" --watch",
|
||||
"compile": "coffee --bare --compile --output ./lib ./src",
|
||||
"compile:watch": "jitter src lib -b",
|
||||
"watch": "npm run compile:watch & npm run test:watch",
|
||||
"winwatch": "start/b npm run compile:watch & npm run test:watch",
|
||||
"prepublish": "npm run compile"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.20",
|
||||
"renderkid": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "~1.9.2",
|
||||
"coffee-script": "~1.8.0",
|
||||
"coffeescript": "^1.12.7",
|
||||
"jitter": "^1.3.0",
|
||||
"mocha": "^8.2.0"
|
||||
},
|
||||
"author": "Aria Minaei",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/AriaMinaei/pretty-error.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/AriaMinaei/pretty-error/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"pretty",
|
||||
"error",
|
||||
"exception",
|
||||
"debug",
|
||||
"error-handling",
|
||||
"readable",
|
||||
"colorful",
|
||||
"prettify",
|
||||
"format",
|
||||
"human"
|
||||
]
|
||||
}
|
232
app_vue/node_modules/pretty-error/src/ParsedError.coffee
generated
vendored
Normal file
232
app_vue/node_modules/pretty-error/src/ParsedError.coffee
generated
vendored
Normal file
@ -0,0 +1,232 @@
|
||||
sysPath = require 'path'
|
||||
|
||||
module.exports = class ParsedError
|
||||
constructor: (@error) ->
|
||||
do @_parse
|
||||
|
||||
_parse: ->
|
||||
@_trace = []
|
||||
@_kind = 'Error'
|
||||
@_wrapper = ''
|
||||
|
||||
@_wrapper = String @error.wrapper if @error.wrapper?
|
||||
|
||||
unless typeof @error is 'object'
|
||||
@_message = String @error
|
||||
else
|
||||
@_stack = @error.stack
|
||||
|
||||
if @error.kind?
|
||||
@_kind = String @error.kind
|
||||
else if typeof @_stack is 'string'
|
||||
if m = @_stack.match /^([a-zA-Z0-9\_\$]+):\ /
|
||||
@_kind = m[1]
|
||||
|
||||
@_message = @error.message? and String(@error.message) or ''
|
||||
if typeof @_stack is 'string'
|
||||
@_parseStack()
|
||||
|
||||
return
|
||||
|
||||
_parseStack: ->
|
||||
messageLines = []
|
||||
reachedTrace = no
|
||||
|
||||
for line in @_stack.split '\n'
|
||||
continue if line.trim() is ''
|
||||
if reachedTrace
|
||||
@_trace.push @_parseTraceItem line
|
||||
else
|
||||
if line.match /^\s*at\s.+/
|
||||
reachedTrace = yes
|
||||
@_trace.push @_parseTraceItem line
|
||||
else if !@_message.split '\n'.indexOf line
|
||||
messageLines.push line
|
||||
|
||||
message = messageLines.join '\n'
|
||||
if message.substr(0, @_kind.length) is @_kind
|
||||
message =
|
||||
message
|
||||
.substr(@_kind.length, message.length)
|
||||
.replace(/^\:\s+/, '')
|
||||
|
||||
if message.length
|
||||
@_message = if @_message.length
|
||||
then [
|
||||
@_message
|
||||
message
|
||||
].join '\n'
|
||||
else
|
||||
message
|
||||
|
||||
return
|
||||
|
||||
_parseTraceItem: (text) ->
|
||||
text = text.trim()
|
||||
|
||||
return if text is ''
|
||||
return text unless text.match /^at\ /
|
||||
|
||||
# remove the 'at ' part
|
||||
text = text.replace /^at /, ''
|
||||
|
||||
return if text in ['Error (<anonymous>)', 'Error (<anonymous>:null:null)']
|
||||
|
||||
original = text
|
||||
|
||||
# the part that comes before the address
|
||||
what = null
|
||||
|
||||
# address, including path to module and line/col
|
||||
addr = null
|
||||
|
||||
# path to module
|
||||
path = null
|
||||
|
||||
# module dir
|
||||
dir = null
|
||||
|
||||
# module basename
|
||||
file = null
|
||||
|
||||
# line number (if using a compiler, the line number of the module
|
||||
# in that compiler will be used)
|
||||
line = null
|
||||
|
||||
# column, same as above
|
||||
col = null
|
||||
|
||||
# if using a compiler, this will translate to the line number of
|
||||
# the js equivalent of that module
|
||||
jsLine = null
|
||||
|
||||
# like above
|
||||
jsCol = null
|
||||
|
||||
# path that doesn't include `node_module` dirs
|
||||
shortenedPath = null
|
||||
|
||||
# like above
|
||||
shortenedAddr = null
|
||||
|
||||
packageName = '[current]'
|
||||
|
||||
# pick out the address
|
||||
if m = text.match /\(([^\)]+)\)$/
|
||||
addr = m[1].trim()
|
||||
|
||||
if addr?
|
||||
what = text.substr 0, text.length - addr.length - 2
|
||||
what = what.trim()
|
||||
|
||||
# might not have a 'what' clause
|
||||
unless addr?
|
||||
addr = text.trim()
|
||||
|
||||
addr = @_fixPath addr
|
||||
remaining = addr
|
||||
|
||||
# remove the <js> clause if the file is a compiled one
|
||||
if m = remaining.match /\,\ <js>:(\d+):(\d+)$/
|
||||
jsLine = m[1]
|
||||
jsCol = m[2]
|
||||
remaining = remaining.substr 0, remaining.length - m[0].length
|
||||
|
||||
# the line/col part
|
||||
if m = remaining.match /:(\d+):(\d+)$/
|
||||
line = m[1]
|
||||
col = m[2]
|
||||
remaining = remaining.substr 0, remaining.length - m[0].length
|
||||
path = remaining
|
||||
|
||||
# file and dir
|
||||
if path?
|
||||
file = sysPath.basename path
|
||||
dir = sysPath.dirname path
|
||||
|
||||
if dir is '.' then dir = ''
|
||||
|
||||
path = @_fixPath path
|
||||
file = @_fixPath file
|
||||
dir = @_fixPath dir
|
||||
|
||||
if dir?
|
||||
d = dir.replace /[\\]{1,2}/g, '/'
|
||||
if m = d.match ///
|
||||
node_modules/([^/]+)(?!.*node_modules.*)
|
||||
///
|
||||
|
||||
packageName = m[1]
|
||||
|
||||
unless jsLine?
|
||||
jsLine = line
|
||||
jsCol = col
|
||||
|
||||
if path?
|
||||
r = @_rectifyPath path
|
||||
shortenedPath = r.path
|
||||
shortenedAddr = shortenedPath + addr.substr(path.length, addr.length)
|
||||
packages = r.packages
|
||||
|
||||
original: original
|
||||
what: what
|
||||
addr: addr
|
||||
path: path
|
||||
dir: dir
|
||||
file: file
|
||||
line: parseInt line
|
||||
col: parseInt col
|
||||
jsLine: parseInt jsLine
|
||||
jsCol: parseInt jsCol
|
||||
packageName: packageName
|
||||
shortenedPath: shortenedPath
|
||||
shortenedAddr: shortenedAddr
|
||||
packages: packages || []
|
||||
|
||||
_getMessage: -> @_message
|
||||
_getKind: -> @_kind
|
||||
_getWrapper: -> @_wrapper
|
||||
_getStack: -> @_stack
|
||||
_getArguments: -> @error.arguments
|
||||
_getType: -> @error.type
|
||||
_getTrace: -> @_trace
|
||||
_fixPath: (path) -> path.replace(///[\\]{1,2}///g, '/')
|
||||
|
||||
_rectifyPath: (path, nameForCurrentPackage) ->
|
||||
path = String path
|
||||
remaining = path
|
||||
|
||||
return path: path, packages: [] unless m = path.match /^(.+?)\/node_modules\/(.+)$/
|
||||
|
||||
parts = []
|
||||
packages = []
|
||||
|
||||
if typeof nameForCurrentPackage is 'string'
|
||||
parts.push "[#{nameForCurrentPackage}]"
|
||||
packages.push "[#{nameForCurrentPackage}]"
|
||||
else
|
||||
parts.push "[#{m[1].match(/([^\/]+)$/)[1]}]"
|
||||
packages.push m[1].match(/([^\/]+)$/)[1]
|
||||
|
||||
rest = m[2]
|
||||
|
||||
while m = rest.match /([^\/]+)\/node_modules\/(.+)$/
|
||||
parts.push "[#{m[1]}]"
|
||||
packages.push m[1]
|
||||
rest = m[2]
|
||||
|
||||
if m = rest.match /([^\/]+)\/(.+)$/
|
||||
parts.push "[#{m[1]}]"
|
||||
packages.push m[1]
|
||||
rest = m[2]
|
||||
|
||||
parts.push rest
|
||||
|
||||
path: parts.join "/"
|
||||
packages: packages
|
||||
|
||||
for prop in ['message', 'kind', 'arguments', 'type', 'stack', 'trace', 'wrapper'] then do ->
|
||||
methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length)
|
||||
|
||||
Object.defineProperty ParsedError::, prop,
|
||||
get: -> this[methodName]()
|
346
app_vue/node_modules/pretty-error/src/PrettyError.coffee
generated
vendored
Normal file
346
app_vue/node_modules/pretty-error/src/PrettyError.coffee
generated
vendored
Normal file
@ -0,0 +1,346 @@
|
||||
isPlainObject = require 'lodash/isPlainObject'
|
||||
defaultStyle = require './defaultStyle'
|
||||
ParsedError = require './ParsedError'
|
||||
nodePaths = require './nodePaths'
|
||||
RenderKid = require 'renderkid'
|
||||
merge = require 'lodash/merge'
|
||||
|
||||
arrayUtils =
|
||||
pluckByCallback: (a, cb) ->
|
||||
return a if a.length < 1
|
||||
removed = 0
|
||||
|
||||
for value, index in a
|
||||
if cb value, index
|
||||
removed++
|
||||
continue
|
||||
|
||||
if removed isnt 0
|
||||
a[index - removed] = a[index]
|
||||
|
||||
if removed > 0
|
||||
a.length = a.length - removed
|
||||
|
||||
a
|
||||
|
||||
pluckOneItem: (a, item) ->
|
||||
return a if a.length < 1
|
||||
reached = no
|
||||
|
||||
for value, index in a
|
||||
if not reached
|
||||
if value is item
|
||||
reached = yes
|
||||
continue
|
||||
else
|
||||
a[index - 1] = a[index]
|
||||
|
||||
a.length = a.length - 1 if reached
|
||||
a
|
||||
|
||||
instance = null
|
||||
|
||||
module.exports = class PrettyError
|
||||
self = @
|
||||
|
||||
@_filters:
|
||||
'module.exports': (item) ->
|
||||
return unless item.what?
|
||||
item.what = item.what.replace /\.module\.exports\./g, ' - '
|
||||
return
|
||||
|
||||
@_getDefaultStyle: ->
|
||||
defaultStyle()
|
||||
|
||||
@start: ->
|
||||
unless instance?
|
||||
instance = new self
|
||||
instance.start()
|
||||
|
||||
instance
|
||||
|
||||
@stop: ->
|
||||
instance?.stop()
|
||||
|
||||
constructor: ->
|
||||
@_useColors = yes
|
||||
@_maxItems = 50
|
||||
@_packagesToSkip = []
|
||||
@_pathsToSkip = []
|
||||
@_skipCallbacks = []
|
||||
@_filterCallbacks = []
|
||||
@_parsedErrorFilters = []
|
||||
@_aliases = []
|
||||
@_renderer = new RenderKid
|
||||
@_style = self._getDefaultStyle()
|
||||
@_renderer.style @_style
|
||||
|
||||
start: ->
|
||||
@_oldPrepareStackTrace = Error.prepareStackTrace
|
||||
|
||||
prepeare = @_oldPrepareStackTrace or (exc, frames) ->
|
||||
result = exc.toString()
|
||||
frames = frames.map (frame) -> " at #{frame.toString()}"
|
||||
result + "\n" + frames.join "\n"
|
||||
|
||||
# https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
|
||||
Error.prepareStackTrace = (exc, trace) =>
|
||||
stack = prepeare.apply(null, arguments)
|
||||
@render {stack, message: exc.toString().replace /^.*: /, ''}, no
|
||||
|
||||
@
|
||||
|
||||
stop: ->
|
||||
Error.prepareStackTrace = @_oldPrepareStackTrace
|
||||
@_oldPrepareStackTrace = null
|
||||
|
||||
config: (c) ->
|
||||
if c.skipPackages?
|
||||
if c.skipPackages is no
|
||||
@unskipAllPackages()
|
||||
else
|
||||
@skipPackage.apply @, c.skipPackages
|
||||
|
||||
if c.skipPaths?
|
||||
if c.skipPaths is no
|
||||
@unskipAllPaths()
|
||||
else
|
||||
@skipPath.apply @, c.skipPaths
|
||||
|
||||
if c.skip?
|
||||
if c.skip is no
|
||||
@unskipAll()
|
||||
else
|
||||
@skip.apply @, c.skip
|
||||
|
||||
if c.maxItems?
|
||||
@setMaxItems c.maxItems
|
||||
|
||||
if c.skipNodeFiles is yes
|
||||
@skipNodeFiles()
|
||||
else if c.skipNodeFiles is no
|
||||
@unskipNodeFiles()
|
||||
|
||||
if c.filters?
|
||||
if c.filters is no
|
||||
@removeAllFilters()
|
||||
else
|
||||
@filter.apply @, c.filters
|
||||
|
||||
if c.parsedErrorFilters?
|
||||
if c.parsedErrorFilters is no
|
||||
@removeAllParsedErrorFilters()
|
||||
else
|
||||
@filterParsedError.apply @, c.parsedErrorFilters
|
||||
|
||||
if c.aliases?
|
||||
if isPlainObject c.aliases
|
||||
@alias path, alias for path, alias of c.aliases
|
||||
else if c.aliases is no
|
||||
@removeAllAliases()
|
||||
|
||||
@
|
||||
|
||||
withoutColors: ->
|
||||
@_useColors = false
|
||||
@
|
||||
|
||||
withColors: ->
|
||||
@_useColors = true
|
||||
@
|
||||
|
||||
skipPackage: (packages...) ->
|
||||
@_packagesToSkip.push String pkg for pkg in packages
|
||||
@
|
||||
|
||||
unskipPackage: (packages...) ->
|
||||
arrayUtils.pluckOneItem(@_packagesToSkip, pkg) for pkg in packages
|
||||
@
|
||||
|
||||
unskipAllPackages: ->
|
||||
@_packagesToSkip.length = 0
|
||||
@
|
||||
|
||||
skipPath: (paths...) ->
|
||||
@_pathsToSkip.push path for path in paths
|
||||
@
|
||||
|
||||
unskipPath: (paths...) ->
|
||||
arrayUtils.pluckOneItem(@_pathsToSkip, path) for path in paths
|
||||
@
|
||||
|
||||
unskipAllPaths: ->
|
||||
@_pathsToSkip.length = 0
|
||||
@
|
||||
|
||||
skip: (callbacks...) ->
|
||||
@_skipCallbacks.push cb for cb in callbacks
|
||||
@
|
||||
|
||||
unskip: (callbacks...) ->
|
||||
arrayUtils.pluckOneItem(@_skipCallbacks, cb) for cb in callbacks
|
||||
@
|
||||
|
||||
unskipAll: ->
|
||||
@_skipCallbacks.length = 0
|
||||
@
|
||||
|
||||
skipNodeFiles: ->
|
||||
@skipPath.apply @, nodePaths
|
||||
|
||||
unskipNodeFiles: ->
|
||||
@unskipPath.apply @, nodePaths
|
||||
|
||||
filter: (callbacks...) ->
|
||||
@_filterCallbacks.push cb for cb in callbacks
|
||||
@
|
||||
|
||||
removeFilter: (callbacks...) ->
|
||||
arrayUtils.pluckOneItem(@_filterCallbacks, cb) for cb in callbacks
|
||||
@
|
||||
|
||||
removeAllFilters: ->
|
||||
@_filterCallbacks.length = 0
|
||||
@
|
||||
|
||||
filterParsedError: (callbacks...) ->
|
||||
@_parsedErrorFilters.push cb for cb in callbacks
|
||||
@
|
||||
|
||||
removeParsedErrorFilter: (callbacks...) ->
|
||||
arrayUtils.pluckOneItem(@_parsedErrorFilters, cb) for cb in callbacks
|
||||
@
|
||||
|
||||
removeAllParsedErrorFilters: ->
|
||||
@_parsedErrorFilters.length = 0
|
||||
@
|
||||
|
||||
setMaxItems: (maxItems = 50) ->
|
||||
if maxItems is 0 then maxItems = 50
|
||||
@_maxItems = maxItems|0
|
||||
@
|
||||
|
||||
alias: (stringOrRx, alias) ->
|
||||
@_aliases.push {stringOrRx, alias}
|
||||
@
|
||||
|
||||
removeAlias: (stringOrRx) ->
|
||||
arrayUtils.pluckByCallback @_aliases, (pair) ->
|
||||
pair.stringOrRx is stringOrRx
|
||||
|
||||
@
|
||||
|
||||
removeAllAliases: ->
|
||||
@_aliases.length = 0
|
||||
@
|
||||
|
||||
_getStyle: ->
|
||||
@_style
|
||||
|
||||
appendStyle: (toAppend) ->
|
||||
merge @_style, toAppend
|
||||
@_renderer.style toAppend
|
||||
@
|
||||
|
||||
_getRenderer: ->
|
||||
@_renderer
|
||||
|
||||
render: (e, logIt = no, useColors = @_useColors) ->
|
||||
obj = @getObject e
|
||||
rendered = @_renderer.render(obj, useColors)
|
||||
console.error rendered if logIt is yes
|
||||
rendered
|
||||
|
||||
getObject: (e) ->
|
||||
unless e instanceof ParsedError
|
||||
e = new ParsedError e
|
||||
|
||||
@_applyParsedErrorFiltersOn e
|
||||
|
||||
header =
|
||||
title: do ->
|
||||
ret = {}
|
||||
|
||||
# some errors are thrown to display other errors.
|
||||
# we call them wrappers here.
|
||||
if e.wrapper isnt ''
|
||||
ret.wrapper = "#{e.wrapper}"
|
||||
|
||||
ret.kind = e.kind
|
||||
ret
|
||||
|
||||
colon: ':'
|
||||
|
||||
message: String(e.message).trim()
|
||||
|
||||
traceItems = []
|
||||
count = -1
|
||||
|
||||
for item, i in e.trace
|
||||
continue unless item?
|
||||
continue if @_skipOrFilter(item, i) is yes
|
||||
|
||||
count++
|
||||
|
||||
break if count > @_maxItems
|
||||
|
||||
if typeof item is 'string'
|
||||
traceItems.push item: custom: item
|
||||
continue
|
||||
|
||||
traceItems.push do ->
|
||||
markupItem = item:
|
||||
header:
|
||||
pointer: do ->
|
||||
return '' unless item.file?
|
||||
|
||||
file: item.file
|
||||
colon: ':'
|
||||
line: item.line
|
||||
|
||||
footer: do ->
|
||||
foooter = addr: item.shortenedAddr
|
||||
if item.extra? then foooter.extra = item.extra
|
||||
foooter
|
||||
|
||||
markupItem.item.header.what = item.what if typeof item.what is 'string' and item.what.trim().length > 0
|
||||
markupItem
|
||||
|
||||
|
||||
obj = 'pretty-error':
|
||||
header: header
|
||||
|
||||
if traceItems.length > 0
|
||||
obj['pretty-error'].trace = traceItems
|
||||
|
||||
obj
|
||||
|
||||
_skipOrFilter: (item, itemNumber) ->
|
||||
if typeof item is 'object'
|
||||
return yes if item.modName in @_packagesToSkip
|
||||
return yes if item.path in @_pathsToSkip
|
||||
|
||||
for modName in item.packages
|
||||
return yes if modName in @_packagesToSkip
|
||||
|
||||
if typeof item.shortenedAddr is 'string'
|
||||
for pair in @_aliases
|
||||
item.shortenedAddr = item.shortenedAddr.replace pair.stringOrRx, pair.alias
|
||||
|
||||
for cb in @_skipCallbacks
|
||||
return yes if cb(item, itemNumber) is yes
|
||||
|
||||
for cb in @_filterCallbacks
|
||||
cb(item, itemNumber)
|
||||
|
||||
return no
|
||||
|
||||
_applyParsedErrorFiltersOn: (error) ->
|
||||
for cb in @_parsedErrorFilters
|
||||
cb error
|
||||
|
||||
return
|
||||
|
||||
for prop in ['renderer', 'style'] then do ->
|
||||
methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length)
|
||||
PrettyError::__defineGetter__ prop, -> do @[methodName]
|
59
app_vue/node_modules/pretty-error/src/defaultStyle.coffee
generated
vendored
Normal file
59
app_vue/node_modules/pretty-error/src/defaultStyle.coffee
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
module.exports = ->
|
||||
'pretty-error':
|
||||
display: 'block'
|
||||
marginLeft: '2'
|
||||
|
||||
'pretty-error > header':
|
||||
display: 'block'
|
||||
|
||||
'pretty-error > header > title > kind':
|
||||
background: 'red'
|
||||
color: 'bright-white'
|
||||
|
||||
'pretty-error > header > title > wrapper':
|
||||
marginRight: '1'
|
||||
color: 'grey'
|
||||
|
||||
'pretty-error > header > colon':
|
||||
color: 'grey'
|
||||
marginRight: 1
|
||||
|
||||
'pretty-error > header > message':
|
||||
color: 'bright-white'
|
||||
|
||||
'pretty-error > trace':
|
||||
display: 'block'
|
||||
marginTop: 1
|
||||
|
||||
'pretty-error > trace > item':
|
||||
display: 'block'
|
||||
marginBottom: 1
|
||||
marginLeft: 2
|
||||
bullet: '"<grey>-</grey>"'
|
||||
|
||||
'pretty-error > trace > item > header':
|
||||
display: 'block'
|
||||
|
||||
'pretty-error > trace > item > header > pointer > file':
|
||||
color: 'bright-yellow'
|
||||
|
||||
'pretty-error > trace > item > header > pointer > colon':
|
||||
color: 'grey'
|
||||
|
||||
'pretty-error > trace > item > header > pointer > line':
|
||||
color: 'bright-yellow'
|
||||
marginRight: 1
|
||||
|
||||
'pretty-error > trace > item > header > what':
|
||||
color: 'white'
|
||||
|
||||
'pretty-error > trace > item > footer':
|
||||
display: 'block'
|
||||
|
||||
'pretty-error > trace > item > footer > addr':
|
||||
display: 'block'
|
||||
color: 'grey'
|
||||
|
||||
'pretty-error > trace > item > footer > extra':
|
||||
display: 'block'
|
||||
color: 'grey'
|
52
app_vue/node_modules/pretty-error/src/nodePaths.coffee
generated
vendored
Normal file
52
app_vue/node_modules/pretty-error/src/nodePaths.coffee
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
module.exports = [
|
||||
'_debugger.js'
|
||||
'_http_agent.js'
|
||||
'_http_client.js'
|
||||
'_http_common.js'
|
||||
'_http_incoming.js'
|
||||
'_http_outgoing.js'
|
||||
'_http_server.js'
|
||||
'_linklist.js'
|
||||
'_stream_duplex.js'
|
||||
'_stream_passthrough.js'
|
||||
'_stream_readable.js'
|
||||
'_stream_transform.js'
|
||||
'_stream_writable.js'
|
||||
'_tls_legacy.js'
|
||||
'_tls_wrap.js'
|
||||
'assert.js'
|
||||
'buffer.js'
|
||||
'child_process.js'
|
||||
'cluster.js'
|
||||
'console.js'
|
||||
'constants.js'
|
||||
'crypto.js'
|
||||
'dgram.js'
|
||||
'dns.js'
|
||||
'domain.js'
|
||||
'events.js'
|
||||
'freelist.js'
|
||||
'fs.js'
|
||||
'http.js'
|
||||
'https.js'
|
||||
'module.js'
|
||||
'net.js'
|
||||
'os.js'
|
||||
'path.js'
|
||||
'punycode.js'
|
||||
'querystring.js'
|
||||
'readline.js'
|
||||
'repl.js'
|
||||
'smalloc.js'
|
||||
'stream.js'
|
||||
'string_decoder.js'
|
||||
'sys.js'
|
||||
'timers.js'
|
||||
'tls.js'
|
||||
'tty.js'
|
||||
'url.js'
|
||||
'util.js'
|
||||
'vm.js'
|
||||
'zlib.js'
|
||||
'node.js'
|
||||
]
|
1
app_vue/node_modules/pretty-error/start.js
generated
vendored
Normal file
1
app_vue/node_modules/pretty-error/start.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
require('./lib/PrettyError').start()
|
87
app_vue/node_modules/pretty-error/test/ParsedError.coffee
generated
vendored
Normal file
87
app_vue/node_modules/pretty-error/test/ParsedError.coffee
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
chai = require 'chai'
|
||||
ParsedError = require '../src/ParsedError'
|
||||
|
||||
chai.should()
|
||||
|
||||
error = (what) ->
|
||||
if typeof what is 'string'
|
||||
return error -> throw Error what
|
||||
|
||||
else if what instanceof Function
|
||||
try
|
||||
do what
|
||||
return null
|
||||
catch e
|
||||
return e
|
||||
|
||||
else
|
||||
throw Error "bad argument for error"
|
||||
|
||||
describe "ParsedError", ->
|
||||
describe "constructor()", ->
|
||||
it "should accept Error() instances", ->
|
||||
(-> new ParsedError error -> throw Error "some message").should.not.throw()
|
||||
|
||||
it "should accept ReferenceError() and other derivatives of Error()", ->
|
||||
(-> new ParsedError error -> throw ReferenceError "some message").should.not.throw()
|
||||
|
||||
it "should accept non errors", ->
|
||||
(-> e = new ParsedError 'some string').should.not.throw()
|
||||
|
||||
describe "message", ->
|
||||
it "should return the original error message", ->
|
||||
e = new ParsedError error 'a'
|
||||
e.message.should.equal 'a'
|
||||
|
||||
describe "multiline message", ->
|
||||
it "should return the original error message", ->
|
||||
e = new ParsedError error 'a \n b \n c'
|
||||
e.message.should.equal 'a \n b \n c'
|
||||
|
||||
describe "kind", ->
|
||||
it "should return 'Error' for normal error", ->
|
||||
e = new ParsedError error 'a'
|
||||
e.kind.should.equal 'Error'
|
||||
|
||||
it "should recognize 'ReferenceError'", ->
|
||||
e = new ParsedError error -> a.b = c
|
||||
e.kind.should.equal 'ReferenceError'
|
||||
|
||||
describe "type", ->
|
||||
it.skip "should return original error type", ->
|
||||
e = new ParsedError error -> a.b = c
|
||||
e.type.should.be.equal 'not_defined'
|
||||
|
||||
describe "arguments", ->
|
||||
it.skip "should return original error arguments", ->
|
||||
e = new ParsedError error -> a.b = c
|
||||
e.arguments.should.be.eql ['a']
|
||||
|
||||
describe "stack", ->
|
||||
it "should return original error stack", ->
|
||||
e = new ParsedError error -> a.b = c
|
||||
e.stack.should.be.equal e.error.stack
|
||||
|
||||
describe "trace", ->
|
||||
it "should include correct information about each trace item", ->
|
||||
e = new ParsedError error -> a.b = c
|
||||
e.trace.should.have.length.above 2
|
||||
|
||||
item = e.trace[0]
|
||||
item.should.include.keys 'original',
|
||||
'what', 'path', 'addr',
|
||||
'file', 'dir', 'col',
|
||||
'line', 'jsCol', 'jsLine'
|
||||
'packageName', 'shortenedPath', 'shortenedAddr'
|
||||
|
||||
item.path.should.equal module.filename.replace(/[\\]+/g, '/')
|
||||
|
||||
item.line.should.be.a 'number'
|
||||
item.col.should.be.a 'number'
|
||||
|
||||
describe "_rectifyPath()", ->
|
||||
it "should work", ->
|
||||
ParsedError::_rectifyPath('F:/a/node_modules/b/node_modules/d/node_modules/e/f.js').path.should.equal '[a]/[b]/[d]/[e]/f.js'
|
||||
|
||||
it "should return path when `node_modules` is not present", ->
|
||||
ParsedError::_rectifyPath('a/b/c').path.should.equal 'a/b/c'
|
109
app_vue/node_modules/pretty-error/test/PrettyError.coffee
generated
vendored
Normal file
109
app_vue/node_modules/pretty-error/test/PrettyError.coffee
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
chai = require 'chai'
|
||||
PrettyError = require '../src/PrettyError'
|
||||
defaultStyle = require '../src/defaultStyle'
|
||||
|
||||
chai.should()
|
||||
|
||||
isFormatted = (exc) ->
|
||||
exc.stack.indexOf(' \u001b[0m\u001b[97m\u001b[41m') is 0
|
||||
|
||||
error = (what) ->
|
||||
if typeof what is 'string'
|
||||
return error -> throw Error what
|
||||
|
||||
else if what instanceof Function
|
||||
try
|
||||
do what
|
||||
catch e
|
||||
return e
|
||||
|
||||
throw Error "bad argument for error"
|
||||
|
||||
describe "PrettyError", ->
|
||||
describe "constructor()", ->
|
||||
it "should work", ->
|
||||
new PrettyError
|
||||
|
||||
describe "getObject", ->
|
||||
it "should return a string", ->
|
||||
p = new PrettyError
|
||||
p.getObject(error "hello").should.be.an 'object'
|
||||
|
||||
describe "style", ->
|
||||
it "should, by default, return the contents in `default-style`", ->
|
||||
p = new PrettyError
|
||||
p.style.should.eql defaultStyle()
|
||||
|
||||
it "should return different contents after appending some styles", ->
|
||||
p = new PrettyError
|
||||
p.appendStyle 'some selector': 'display': 'block'
|
||||
p.style.should.not.eql defaultStyle()
|
||||
|
||||
describe "render()", ->
|
||||
it "should work", ->
|
||||
p = new PrettyError
|
||||
p.skipNodeFiles()
|
||||
p.appendStyle 'pretty-error': marginLeft: 4
|
||||
|
||||
e = error -> "a".should.equal "b"
|
||||
console.log p.render e, no
|
||||
|
||||
e2 = error -> Array.split(Object)
|
||||
console.log p.render e2, no
|
||||
|
||||
e3 = "Plain error message"
|
||||
console.log p.render e3, no
|
||||
|
||||
e4 =
|
||||
message: "Custom error message"
|
||||
kind: "Custom Error"
|
||||
|
||||
console.log p.render e4, no
|
||||
|
||||
e5 =
|
||||
message: "Error with custom stack"
|
||||
stack: ['line one', 'line two']
|
||||
wrapper: 'UnhandledRejection'
|
||||
|
||||
console.log p.render e5, no
|
||||
|
||||
e6 = error -> PrettyError.someNonExistingFuncion()
|
||||
console.log p.render e6, no
|
||||
|
||||
it.skip "should render without colors if pe._useColors is false", ->
|
||||
p = new PrettyError
|
||||
p.withoutColors()
|
||||
p.skipNodeFiles()
|
||||
p.appendStyle 'pretty-error': marginLeft: 4
|
||||
|
||||
e = error -> "a".should.equal "b"
|
||||
console.log p.render e, no
|
||||
|
||||
describe "start()", ->
|
||||
prepareStackTrace = null
|
||||
|
||||
beforeEach ->
|
||||
{prepareStackTrace} = Error
|
||||
Error.prepareStackTrace = null
|
||||
|
||||
afterEach ->
|
||||
Error.prepareStackTrace = prepareStackTrace
|
||||
|
||||
it "throws unformatted error when not started", ->
|
||||
try
|
||||
throw new Error "foo bar"
|
||||
catch exc
|
||||
|
||||
isFormatted(exc).should.be.eql false
|
||||
|
||||
it "throws formatted the error", ->
|
||||
PrettyError.start()
|
||||
|
||||
try
|
||||
throw new Error "foo bar"
|
||||
catch exc
|
||||
|
||||
isFormatted(exc).should.be.eql true
|
||||
exc.stack.split(/\n/g).length.should.be.above 2
|
||||
|
||||
PrettyError.stop()
|
Reference in New Issue
Block a user