(token, messageFormat)
| 1835 | // Throw an exception |
| 1836 | |
| 1837 | function throwError(token, messageFormat) { |
| 1838 | var error, |
| 1839 | args = Array.prototype.slice.call(arguments, 2), |
| 1840 | msg = messageFormat.replace( |
| 1841 | /%(\d)/g, |
| 1842 | function (whole, index) { |
| 1843 | assert(index < args.length, 'Message reference must be in range'); |
| 1844 | return args[index]; |
| 1845 | } |
| 1846 | ); |
| 1847 | |
| 1848 | if (typeof token.lineNumber === 'number') { |
| 1849 | error = new Error('Line ' + token.lineNumber + ': ' + msg); |
| 1850 | error.index = token.start; |
| 1851 | error.lineNumber = token.lineNumber; |
| 1852 | error.column = token.start - lineStart + 1; |
| 1853 | } else { |
| 1854 | error = new Error('Line ' + lineNumber + ': ' + msg); |
| 1855 | error.index = index; |
| 1856 | error.lineNumber = lineNumber; |
| 1857 | error.column = index - lineStart + 1; |
| 1858 | } |
| 1859 | |
| 1860 | error.description = msg; |
| 1861 | throw error; |
| 1862 | } |
| 1863 | |
| 1864 | function throwErrorTolerant() { |
| 1865 | try { |
no test coverage detected