<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: ParseError.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: ParseError.js</h1>

    


    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>'use strict'

/**
 * @class
 * @param {string} message
 * @param {Header|Obj} [...el] The element that caused the error (null if not applicable)
 * @extends Error
 */
function ParseError(message) {
	Error.call(this)

	/** @member {string} */
	this.message = message

	/** @member {Array&lt;Header|Obj>} */
	this.els = [].slice.call(arguments, 1)
}

require('util').inherits(ParseError, Error)

/**
 * Populate the error message with the original code region that caused the error
 * @param {string[]} originalLines
 */
ParseError.prototype.addSourceContext = function (originalLines) {
	var start = Infinity,
		end = -Infinity,
		str = '\n\n-----',
		i, focus, checkElFocus

	if (!this.els.length) {
		return
	}
	this.els.forEach(function (el) {
		start = Math.min(start, el.source.begin)
		end = Math.max(end, el.source.end)
	})

	checkElFocus = function (el) {
		return i >= el.source.begin &amp;&amp; i &lt; el.source.end
	}

	for (i = Math.max(0, start - 3); i &lt; end + 3 &amp;&amp; i &lt; originalLines.length; i++) {
		focus = this.els.some(checkElFocus)
		str += '\n' + (focus ? '>' : ' ') + ' ' + originalLines[i]
	}
	str += '\n-----'

	this.message += str
}

module.exports = ParseError</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Case.html">Case</a></li><li><a href="Clear.html">Clear</a></li><li><a href="Declaration.html">Declaration</a></li><li><a href="Find.html">Find</a></li><li><a href="Header.html">Header</a></li><li><a href="Insertion.html">Insertion</a></li><li><a href="Mixin.html">Mixin</a></li><li><a href="Obj.html">Obj</a></li><li><a href="ParseError.html">ParseError</a></li><li><a href="Test.html">Test</a></li></ul><h3>Global</h3><ul><li><a href="global.html#add">add</a></li><li><a href="global.html#eat">eat</a></li><li><a href="global.html#readPath">readPath</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Tue Aug 26 2014 23:08:57 GMT-0300 (Hora oficial do Brasil)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>