[libc++][NFC] Move format_error to its own header.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D101723

NOKEYCHECK=True
GitOrigin-RevId: 16342e39947bca83b25c251a65c7ea86a244a092
diff --git a/include/format b/include/format
index d9d43d8..d755062 100644
--- a/include/format
+++ b/include/format
@@ -56,14 +56,10 @@
 */
 
 #include <__config>
-#include <stdexcept>
+#include <__format/format_error.h>
 #include <string_view>
 #include <version>
 
-#ifdef _LIBCPP_NO_EXCEPTIONS
-#include <cstdlib>
-#endif
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
@@ -75,31 +71,12 @@
 
 #if _LIBCPP_STD_VER > 17
 
-class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error {
-public:
-  _LIBCPP_INLINE_VISIBILITY explicit format_error(const string& __s)
-      : runtime_error(__s) {}
-  _LIBCPP_INLINE_VISIBILITY explicit format_error(const char* __s)
-      : runtime_error(__s) {}
-  virtual ~format_error() noexcept;
-};
-
 // TODO FMT Remove this once we require compilers with proper C++20 support.
 // If the compiler has no concepts support, the format header will be disabled.
 // Without concepts support enable_if needs to be used and that too much effort
 // to support compilers with partial C++20 support.
 #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
 
-_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void
-__throw_format_error(const char* __s) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-  throw format_error(__s);
-#else
-  (void)__s;
-  _VSTD::abort();
-#endif
-}
-
 template <class _CharT>
 class _LIBCPP_TEMPLATE_VIS basic_format_parse_context {
 public: