<commit_before>defmodule Dicer do
  alias Dicer.Validator
  alias Dicer.Lexer
  alias Dicer.Roller
  alias Dicer.Parser

  def roll(input) when is_binary(input) do
    input
    |> _sanitize
    |> Validator.validate
    |> Lexer.tokenize
    |> Roller.roll_dice
    |> Parser.evaluate
  end

  def roll(input) do
    input
    |> Validator.validate
    |> Lexer.tokenize
    |> Roller.roll_dice
    |> Parser.evaluate
  end

  defp _sanitize(input) do
    String.replace(input, ~r/\s/, "")
  end
end<commit_msg>Added roll! which raises an error with error message(s) instead of return an :error tuple<commit_after>defmodule Dicer do
  alias Dicer.Validator
  alias Dicer.Lexer
  alias Dicer.Roller
  alias Dicer.Parser

  def roll(input) when is_binary(input) do
    input
    |> _sanitize
    |> Validator.validate
    |> Lexer.tokenize
    |> Roller.roll_dice
    |> Parser.evaluate
  end

  def roll(_input) do
    {:error, ["Not a string!"]}
  end

  def roll!(input) when is_binary(input) do
    result = 
      input
      |> roll

    case result do
      {:error, messages} ->
        raise "\n" <> Enum.join(messages, "\n") <> "\n"
      _ ->
        result
    end
  end

  def roll!(_input) do
    raise "Not a string!"
  end

  defp _sanitize(input) do
    String.replace(input, ~r/\s/, "")
  end
end
{'fraction_non_alphanumeric': 0.10967250571210967, 'fraction_numerical': 0.0, 'mean_word_length': 2.5513513513513515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3653052', 'n_tokens_mistral': 479, 'n_tokens_neox': 449, 'n_words': 119}