p = q;
if (p == end || *p != '}') {
- throw BadFormatArg("folly::format: single '}' in format string");
+ throwBadFormatArg("folly::format: single '}' in format string");
}
++p;
}
p = q + 1;
if (p == end) {
- throw BadFormatArg("folly::format: '}' at end of format string");
+ throwBadFormatArg("folly::format: '}' at end of format string");
}
// "{{" -> "{"
// Format string
q = static_cast<const char*>(memchr(p, '}', size_t(end - p)));
if (q == nullptr) {
- throw BadFormatArg("folly::format: missing ending '}'");
+ throwBadFormatArg("folly::format: missing ending '}'");
}
FormatArg arg(StringPiece(p, q));
p = q + 1;
}
if (hasDefaultArgIndex && hasExplicitArgIndex) {
- throw BadFormatArg(
+ throwBadFormatArg(
"folly::format: may not have both default and explicit arg indexes");
}
template <class FormatCallback>
void formatString(StringPiece val, FormatArg& arg, FormatCallback& cb) {
if (arg.width != FormatArg::kDefaultWidth && arg.width < 0) {
- throw BadFormatArg("folly::format: invalid width");
+ throwBadFormatArg("folly::format: invalid width");
}
if (arg.precision != FormatArg::kDefaultPrecision && arg.precision < 0) {
- throw BadFormatArg("folly::format: invalid precision");
+ throwBadFormatArg("folly::format: invalid precision");
}
if (arg.precision != FormatArg::kDefaultPrecision &&
--- /dev/null
+/*
+ * Copyright 2017 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <folly/FormatArg.h>
+
+namespace folly {
+
+[[noreturn]] void throwBadFormatArg(char const* msg) {
+ throw BadFormatArg(msg);
+}
+[[noreturn]] void throwBadFormatArg(std::string const& msg) {
+ throw BadFormatArg(msg);
+}
+}
namespace folly {
class BadFormatArg : public std::invalid_argument {
- public:
- explicit BadFormatArg(const std::string& msg)
- : std::invalid_argument(msg) {}
+ using invalid_argument::invalid_argument;
};
+[[noreturn]] void throwBadFormatArg(char const* msg);
+[[noreturn]] void throwBadFormatArg(std::string const& msg);
+
/**
* Parsed format argument.
*/
template <typename... Args>
[[noreturn]] inline void FormatArg::error(Args&&... args) const {
- throw BadFormatArg(errorStr(std::forward<Args>(args)...));
+ throwBadFormatArg(errorStr(std::forward<Args>(args)...));
}
template <bool emptyOk>
detail/RangeCommon.cpp \
EscapeTables.cpp \
Format.cpp \
+ FormatArg.cpp \
FormatTables.cpp \
MallctlHelper.cpp \
portability/BitsFunctexcept.cpp \