forError<T> static method

ParseResult<T> forError<T>(
  1. Error errorProvider()
)

Produces a ParseResult which represents a failed parsing operation.

This method accepts a delegate rather than the exception itself, as creating an exception can be relatively slow: if the client doesn't need the actual exception, just the information that the parse failed, there's no point in creating the exception.

  • errorProvider: A delegate that produces the exception representing the error that caused the parse to fail.

Returns: A ParseResult representing a failed parsing operation.

Implementation

static ParseResult<T> forError<T>(Error Function() errorProvider) =>
    ParseResult<T>._error(Preconditions.checkNotNull(errorProvider, 'errorProvider'), false);