Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / handlebars / lib / handlebars / exception.js
1
2 const errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
3
4 function Exception(message, node) {
5   let loc = node && node.loc,
6       line,
7       column;
8   if (loc) {
9     line = loc.start.line;
10     column = loc.start.column;
11
12     message += ' - ' + line + ':' + column;
13   }
14
15   let tmp = Error.prototype.constructor.call(this, message);
16
17   // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
18   for (let idx = 0; idx < errorProps.length; idx++) {
19     this[errorProps[idx]] = tmp[errorProps[idx]];
20   }
21
22   /* istanbul ignore else */
23   if (Error.captureStackTrace) {
24     Error.captureStackTrace(this, Exception);
25   }
26
27   try {
28     if (loc) {
29       this.lineNumber = line;
30
31       // Work around issue under safari where we can't directly set the column value
32       /* istanbul ignore next */
33       if (Object.defineProperty) {
34         Object.defineProperty(this, 'column', {value: column});
35       } else {
36         this.column = column;
37       }
38     }
39   } catch (nop) {
40     /* Ignore if the browser is very particular */
41   }
42 }
43
44 Exception.prototype = new Error();
45
46 export default Exception;