-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror.js
More file actions
33 lines (27 loc) · 700 Bytes
/
Copy patherror.js
File metadata and controls
33 lines (27 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Error module
*
* var error = require('./error')
*
* error('Something happened', {line: 7, col: 22})
* error('Something else happened', {line: 70, col: 1})
* error('That\'s strange')
* console.log(error.count)
*/
function error(message, location) {
if (location && location.line) {
message = message.concat(' at line ', location.line)
if (location.col) {
message = message.concat(', column ', location.col)
}
} else if (location && location.path) {
message = message.concat(', found ', location.path)
}
if (!error.quiet) {
console.log('Error: ' + message)
}
error.count++
}
error.quiet = false
error.count = 0
module.exports = error