Initial commit
[yaffs-website] / node_modules / js-yaml / lib / js-yaml / exception.js
1 // YAML error class. http://stackoverflow.com/questions/8458984
2 //
3 'use strict';
4
5 function YAMLException(reason, mark) {
6   // Super constructor
7   Error.call(this);
8
9   // Include stack trace in error object
10   if (Error.captureStackTrace) {
11     // Chrome and NodeJS
12     Error.captureStackTrace(this, this.constructor);
13   } else {
14     // FF, IE 10+ and Safari 6+. Fallback for others
15     this.stack = (new Error()).stack || '';
16   }
17
18   this.name = 'YAMLException';
19   this.reason = reason;
20   this.mark = mark;
21   this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
22 }
23
24
25 // Inherit from Error
26 YAMLException.prototype = Object.create(Error.prototype);
27 YAMLException.prototype.constructor = YAMLException;
28
29
30 YAMLException.prototype.toString = function toString(compact) {
31   var result = this.name + ': ';
32
33   result += this.reason || '(unknown reason)';
34
35   if (!compact && this.mark) {
36     result += ' ' + this.mark.toString();
37   }
38
39   return result;
40 };
41
42
43 module.exports = YAMLException;