         actual_exception = error.__struct__
         actual_message = Exception.message(error)
 
-        message =
+        failed =
           cond do
             actual_exception != exception ->
               "Doctest failed: expected exception #{inspect(exception)} but got " <>

              nil
          end

        if message do
          reraise ExUnit.AssertionError, [message: message, doctest: doctest], stack
        end
    else
      _ ->
        message =
          "Doctest failed: expected exception #{inspect(exception)} but nothing was raised"

        error = [message: message, doctest: doctest]
        reraise ExUnit.AssertionError, error, stack
    end
  end


    quote do
      stack = unquote(stack)
      message = unquote(message)
      formatted = unquote(formatted)
      exception = unquote(exception)
      ExUnit.DocTest.__error__(fn -> unquote(expr_ast) end, message, exception, formatted, stack)
    end
  end

  @doc false
  def __test__(value, expected, formatted, last_expr, expected_expr, stack) do
    case value do
      ^expected ->
        :ok

      _ ->
        error = [
          message: "Doctest failed",
          doctest: "\n" <> formatted <> "\n" <> expected_expr,
          expr: "#{last_expr} === #{String.trim(expected_expr)}",
          left: value,
          right: expected
        ]

