VerifiedErrors

parsley.errors.patterns$.VerifiedErrors
final implicit class VerifiedErrors[P, A](p: P)(implicit con: P => Parsley[A])

This class exposes combinators related to the Verified Errors parser design pattern.

This extension class operates on values that are convertible to parsers. The combinators it enables allow for the parsing of known illegal values, providing richer error messages in case they succeed.

Attributes

P

the type of base value that this class is used on (the conversion to Parsley) is summoned automatically.

con

a conversion that allows values convertible to parsers to be used.

p

the value that this class is enabling methods on.

Constructor:

This constructor should not be called manually, it is designed to be used via Scala's implicit resolution.

Since:

4.2.0

Source:
patterns.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def verifiedFail(msggen: A => Seq[String]): Parsley[Nothing]

Ensures this parser does not succeed, failing with a specialised error based on this parsers result if it does.

Ensures this parser does not succeed, failing with a specialised error based on this parsers result if it does.

If this parser succeeds, input is consumed and this combinator will fail, producing an error message based on the parsed result. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.

Attributes

msggen

the function that generates the error messages from the parsed value.

Since:

4.2.0

Note:

when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if amend had been used) and the caret will span the entire successful parse of this parser.

when this parser is not to be considered as a terminal error, use attempt around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).

Source:
patterns.scala
def verifiedFail(msg0: String, msgs: String*): Parsley[Nothing]

Ensures this parser does not succeed, failing with a specialised error if it does.

Ensures this parser does not succeed, failing with a specialised error if it does.

If this parser succeeds, input is consumed and this combinator will fail, producing an error message based on the given messages. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.

Attributes

msg0

the first message in the error message.

msgs

the remaining messages that will make up the error message.

Since:

4.2.0

Note:

when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if amend had been used) and the caret will span the entire successful parse of this parser.

when this parser is not to be considered as a terminal error, use attempt around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).

Source:
patterns.scala

Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse.

Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse.

If this parser succeeds, input is consumed and this combinator will fail, producing an unexpected message the same width as the parse. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.

Attributes

Since:

4.2.0

Note:

when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if amend had been used) and the caret will span the entire successful parse of this parser.

when this parser is not to be considered as a terminal error, use attempt around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).

Source:
patterns.scala
def verifiedUnexpected(reason: String): Parsley[Nothing]

Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a given reason.

Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a given reason.

If this parser succeeds, input is consumed and this combinator will fail, producing an unexpected message the same width as the parse along with the given reason. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.

Attributes

reason

the reason that this parser is illegal.

Since:

4.2.0

Note:

when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if amend had been used) and the caret will span the entire successful parse of this parser.

when this parser is not to be considered as a terminal error, use attempt around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).

Source:
patterns.scala
def verifiedUnexpected(reason: A => String): Parsley[Nothing]

Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a reason generated from this parser's result.

Ensures this parser does not succeed, failing with a vanilla error with an unexpected message and caret spanning the parse and a reason generated from this parser's result.

If this parser succeeds, input is consumed and this combinator will fail, producing an unexpected message the same width as the parse along with a reason generated from the successful parse. However, if this parser fails, no input is consumed and an empty error is generated. This parser will produce no labels if it fails.

Attributes

reason

a function that produces a reason for the error given the parsed result.

Since:

4.2.0

Note:

when this combinator fails (and not this parser itself), it will generate errors rooted at the start of the parse (as if amend had been used) and the caret will span the entire successful parse of this parser.

when this parser is not to be considered as a terminal error, use attempt around the entire combinator to allow for backtracking if this parser succeeds (and therefore fails).

Source:
patterns.scala