UNPKG

parjs

Version:

A parser-combinator library for JavaScript.

34 lines (33 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * A parent class for all errors thrown by Parjs. */ class ParjsError extends Error { constructor() { super(...arguments); this.name = this.constructor.name; } } exports.ParjsError = ParjsError; /** * An error that is thrown when it is assumed a parser will succeed, but it fails. */ class ParjsParsingFailure extends ParjsError { constructor(failure) { super(`Expected parsing to succeeded, but it failed. Reason: ${failure.trace.reason}`); this.failure = failure; } } exports.ParjsParsingFailure = ParjsParsingFailure; /** * An error thrown to indicate that a parser has been constructed inappropriately. */ class ParserDefinitionError extends ParjsError { constructor(parserName, message) { super(`${parserName}: ${message}`); this.parserName = parserName; } } exports.ParserDefinitionError = ParserDefinitionError; //# sourceMappingURL=errors.js.map