<commit_before>defmodule Appsignal.DemoBehaviour do
  @callback create_transaction_error_request :: Appsignal.Transaction.t
  @callback create_transaction_performance_request :: Appsignal.Transaction.t
end

defmodule Appsignal.Demo do
  import Appsignal.Instrumentation.Helpers, only: [instrument: 4]

  @behaviour Appsignal.DemoBehaviour

  @doc false
  @spec create_transaction_error_request :: Appsignal.Transaction.t
  def create_transaction_error_request do
    create_demo_transaction()
    |> Appsignal.Transaction.set_error(
      "TestError",
      "Hello world! This is an error used for demonstration purposes.",
      []
    )
    |> finish_demo_transaction()
  end

  @doc false<commit_msg>Raise and rescue error in demo task<commit_after>defmodule Appsignal.DemoBehaviour do
  @callback create_transaction_error_request :: Appsignal.Transaction.t
  @callback create_transaction_performance_request :: Appsignal.Transaction.t
end

defmodule TestError do
  defexception message: "Hello world! This is an error used for demonstration purposes."
end

defmodule Appsignal.Demo do
  import Appsignal.Instrumentation.Helpers, only: [instrument: 4]

  @behaviour Appsignal.DemoBehaviour

  @doc false
  @spec create_transaction_error_request :: Appsignal.Transaction.t
  def create_transaction_error_request do
    try do
      raise TestError
    rescue
      error ->
        create_demo_transaction()
        |> Appsignal.Transaction.set_error("TestError", error.message, System.stacktrace())
        |> finish_demo_transaction()
    end
  end

  @doc false
{'fraction_non_alphanumeric': 0.07088122605363985, 'fraction_numerical': 0.001277139208173691, 'mean_word_length': 4.556737588652482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '5134421', 'n_tokens_mistral': 454, 'n_tokens_neox': 430, 'n_words': 109}