如何使用相对路径进行错误?

时间:2015-06-26 22:36:09

标签: javascript

我遇到的所有错误都使用绝对文件路径,我觉得它让控制台陷入困境:

Error: Example Error
at fail (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:276:11)
at assertEquals (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:272:7)
at assertPointEquals (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:262:5)
at assertCreatesHWall (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:258:5)
at testMazeStartingPointCreatesEdgeWall (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:243:5)
at run (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:290:7)
at runTestsFromList (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:285:7)
at runTests (file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:223:5)
at file:///C:/Users/Kris/Projects/Programming/Javascript/maze_generation/src/maze.js:373:13

我觉得如果排除无关紧要的信息会更容易看到相关信息。也许像这样的事情:

Error: Example Error
at fail (file:./maze.js:276:11)
at assertEquals (file:./maze.js:272:7)
at assertPointEquals (file:./maze.js:262:5)
at assertCreatesHWall (file:./maze.js:258:5)
at testMazeStartingPointCreatesEdgeWall (file:./maze.js:243:5)
at run (file:./maze.js:290:7)
at runTestsFromList (file:./maze.js:285:7)
at runTests (file:./maze.js:223:5)
at file:./maze.js:373:13

有没有办法改变它,还是全部关闭?

1 个答案:

答案 0 :(得分:0)

您正在使用的控制台中可能有配置。

我要做的是运行本地服务器。建立一个基本的是相当简单的。查看NodeJS主页上有一些如何使用几行代码执行此操作的示例。

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');