messageFromError function

String messageFromError(
  1. PintoError error
)

Implementation

String messageFromError(PintoError error) {
  return switch (error) {
    // Parse errors
    ExpectError error => expectError('${error.expectation}', error.token.lexeme),
    ExpectAfterError error => expectAfterError('${error.expectation}', '${error.after}', error.token.lexeme),
    ExpectBeforeError error => expectBeforeError('${error.expectation}', '${error.before}', error.token.lexeme),

    // Resolve errors
    ImportedPackageNotAvailableError error => importedPackageNotAvailableError(error.token.lexeme),
    SymbolNotInScopeError error => symbolNotInScopeError(error.token.lexeme),
    TypeParameterAlreadyDefinedError error => typeParameterAlreadyDefinedError(error.token.lexeme),
    WrongNumberOfArgumentsError error => wrongNumberOfArgumentsError(error.argumentsCount, error.expectedArgumentsCount, error.token.lexeme),

    // Scan errors
    UnexpectedCharacterError error => unexpectedCharacterError(error.character),
  };
}