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

  end

  @doc false
  def __inspect__(value, expected, doctest, expr, parent_stack) do
    result =
      try do
        inspect(value, safe: false)

        actual_exception = error.__struct__
        actual_message = Exception.message(error)

        failed =
          cond do
            actual_exception != exception ->
              "Doctest failed: expected exception #{inspect(exception)} but got " <>
